CSS3 Animation door Open

Source: Internet
Author: User

First, start with <body></body>

And then write the front door of the CSS, as follows: [due to my design is not good, so the door is used to replace the color, everyone in use when you can change the background of various doors]
div{
margin:0;
padding:0;
}
. door{
width:450px;
height:450px;
position:relative;
Background: #a1a1a1;
}
. Door. Leftdoor,.door. rightdoor{
Position:absolute;
width:224px;
height:400px;
top:57px;
top:50px;
Background: #d1d1d1;
}
. Door. leftdoor{
left:0;
border-right:1px solid #999;
box-shadow:inset-2px-2px 10px rgba (0, 0, 0, 0.1);
-webkit-animation:leftdoor 5s 1;
-moz-animation:leftdoor 5s 1;
-o-animation:leftdoor 5s 1;
Animation:leftdoor 5s 1;
-webkit-transform-origin:0% 40%;
-moz-transform-origin:0% 40%;
-o-transform-origin:0% 40%;
transform-origin:0% 40%;
}
. Door. rightdoor{
right:0;
border-left:1px solid #999;
Box-shadow:inset 2px-2px 10px rgba (0, 0, 0, 0.1);
-webkit-animation:rightdoor 5s 1;
-moz-animation:rightdoor 5s 1;
-o-animation:rightdoor 5s 1;
Animation:rightdoor 5s 1;
-webkit-transform-origin:100% 40%;
-moz-transform-origin:100% 40%;
-o-transform-origin:100% 40%;
transform-origin:100% 40%;
}

Add animations to the left door first
@-webkit-keyframes Leftdoor {
0%,100% {
-webkit-transform-origin:0% 40%;
}
0{
-webkit-transform:perspective (0) rotatey (0);
}
100% {
-webkit-transform:perspective (600px) Rotatey (70deg);
}
}
@-moz-keyframes Leftdoor {
0%,100% {
-moz-transform-origin:0% 40%;
}
0{
-moz-transform:perspective (0) rotatey (0);
}
100% {
-moz-transform:perspective (600px) Rotatey (70deg);
}
}
@-o-keyframes Leftdoor {
0%,100% {
-o-transform-origin:0% 40%;
}
0{
-o-transform:perspective (0) rotatey (0);
}
100% {
-o-transform:perspective (600px) Rotatey (70deg);
}
}
@keyframes Leftdoor {
0%,100% {
transform-origin:0% 40%;
}
0{
Transform:perspective (0) rotatey (0);
}
100% {
Transform:perspective (600px) Rotatey (70deg);
}
}

Then add the CSS3 animation for the right door, as long as it changes the corresponding place.
@-webkit-keyframes Rightdoor {
0%,100% {
-webkit-transform-origin:100% 40%;
}
0{
-webkit-transform:perspective (0) rotatey (0);
}
100% {
-webkit-transform:perspective (600px) Rotatey ( -70deg);
}
}
@-moz-keyframes Rightdoor {
0%,100% {
-moz-transform-origin:100% 40%;
}
0{
-moz-transform:perspective (0) rotatey (0);
}
100% {
-moz-transform:perspective (600px) Rotatey ( -70deg);
}
}
@-o-keyframes Rightdoor {
0%,100% {
-o-transform-origin:100% 40%;
}
0{
-o-transform:perspective (0) rotatey (0);
}
100% {
-o-transform:perspective (600px) Rotatey ( -70deg);
}
}
@keyframes Rightdoor {
0%,100% {
transform-origin:100% 40%;
}
0{
Transform:perspective (0) rotatey (0);
}
100% {
Transform:perspective (600px) Rotatey ( -70deg);
}
}

5
The animations here are mainly used by rotate and perspective.
6
If you want the animation to open the door after the click, you can add a button, and then JS control

CSS3 Animation door Open

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.