CSS3 implementing the sidebar unwinding animation

Source: Internet
Author: User
This article mainly describes how to use the CSS3 implementation of the sidebar to expand the animation, and attached the sample code, very detailed, recommended to the needs of the small partners.

@keyframes

Rules are used to create animations.

A CSS style is specified in the @keyframes to create an animated effect that changes from the current style to the new style.

When you create an animation in @keyframes, bundle it to a selector, or it will not animate.

You can bind an animation to a selector by stipulating at least the following two CSS3 animation properties:

Specify the name of the animation
Specify the duration of the animation
Animation

The animation property is a shorthand property that sets the animation properties:

Animation-name: Specifies the name of the @keyframes animation.
Animation-duration: Specifies the seconds or milliseconds that the animation takes to complete a cycle. The default is 0.
Animation-timing-function: Specifies the speed curve of the animation. The default is "ease".
Animation-delay: Specifies when the animation starts. Default is 0
Animation-iteration-count: Specifies the number of times the animation is played. The default is 1.
Animation-direction: Specifies whether the animation will play backwards in the next cycle. The default is "normal".
Animation-fill-mode: Specifies the state outside the animation time of the object

Side Bar Implementation

/* Animation definition */@-webkit-keyframes Move_right {from {opacity:0;        } to {opacity:1;        -webkit-transform:translatex (120px);    Transform:translatex (120px);    }} @keyframes Move_right {from {opacity:0;        } to {opacity:1;        -webkit-transform:translatex (120px);    Transform:translatex (120px);    }}@-webkit-keyframes Move_left {from {opacity:1;        } to {opacity:0;        -webkit-transform:translatex ( -120px);    Transform:translatex ( -120px);    }} @keyframes Move_left {from {opacity:1;        } to {opacity:0;        -webkit-transform:translatex ( -120px);    Transform:translatex ( -120px);    }}@-webkit-keyframes Move_up {from {opacity:0;        } to {opacity:1;        -webkit-transform:translatey ( -250px);    Transform:translatey ( -250px);    }} @keyframes move_up {from {opacity:0;        } to {opacity:1; -webkit-transforM:translatey ( -250px);    Transform:translatey ( -250px); }}
/* Animation binding */. move_right {-webkit-animation-name:move_right;     Animation-name:move_right;     -webkit-animation-duration:1s;     Animation-duration:1s;     -webkit-animation-iteration-count:1;     Animation-iteration-count:1;     -webkit-animation-fill-mode:forwards; Animation-fill-mode:forwards;     }. move_left {-webkit-animation-name:move_left;     Animation-name:move_left;     -webkit-animation-duration:1s;     Animation-duration:1s;     -webkit-animation-iteration-count:1;     Animation-iteration-count:1;     -webkit-animation-fill-mode:forwards; Animation-fill-mode:forwards;     }. move_up {-webkit-animation-name:move_up;     ANIMATION-NAME:MOVE_UP;     -webkit-animation-duration:1s;     Animation-duration:1s;     -webkit-animation-iteration-count:1;     Animation-iteration-count:1; -webkit-animation-fill-mode: forwards; Animation-fill-mode:forwards;     }. fadeIn {-webkit-transform:translatex (120px);      Transform:translatex (120px); Opacity:1;     }. Fadeinup {-webkit-transform:translatey ( -250px);     Transform:translatey ( -250px);     Opacity:1;      -webkit-transition:-webkit-transform. 2s ease-out,opacity. 2s ease-out; Transition:transform. 2s ease-out, opacity. 2s ease-out;     }. Fadeoutleft {-webkit-transform:translatex ( -120px);      Transform:translatex ( -120px);     opacity:0.0;      -webkit-transition:-webkit-transform. 2s ease-out,opacity. 2s ease-out; Transition:transform. 2s ease-out, opacity. 2s ease-out; }

Html

<!doctype html> 

Add JS

<script> var Sidebarel = Document.queryselector (". Sidebar"); function FadeIn (e) {     sidebarel.classname = ' sidebar fullheight ';     SidebarEl.style.top = ' 0px ';     SidebarEl.style.left = ' 0px ';     SidebarEl.classList.add (' move_right '); } function FadeOut (e) {     sidebarel.classname = ' sidebar fullheight ';     SidebarEl.style.left = ' 120px ';     SidebarEl.classList.add (' Move_left '); } function Fadeinup (e) {     sidebarel.classname = ' sidebar fullheight ';     SidebarEl.style.top = ' 250px ';     SidebarEl.style.left = ' 120px ';     SidebarEl.classList.add (' move_up '); } function Fadeoutleft (e) {     sidebarel.classname = ' sidebar fullheight ';     SidebarEl.style.top = ' 0px ';     SidebarEl.style.left = ' 120px ';     SidebarEl.classList.add (' Move_left '); } </script>

The above is the use of CSS3 production side bar animation effect of all the content and code, the small partners according to their own project needs to improve the landscaping can be OH.

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.