CSS3 implementation of the mouse suspension door closing Effect code example:
This section shares a code example that uses the CSS3 simulation to achieve a simple open door closing effect.
The code example is as follows:
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "Utf-8"> <Metaname= "Author"content= "http://www.softwhy.com/" /> <title>Ant Tribe</title><style>. Door{position:relative;width:400px;Height:300px;Overflow:Hidden;Border:2px solid #000;background:#000;}. Door:before,.door:after{content:"';position:Absolute; Left:0;width:0;Height:0;Overflow:Hidden;Border-color:#000 Transparent Transparent transparent;Border-style:Solid;Border-width:0 200px;Z-index:2;transition:All . 8s Ease;}. Door:before{Top:0;}. Door:after{Bottom:0;Border-color:transparent transparent #000 transparent;}. Door:hover:before,.door:hover:after{Border-width:40px 200px;}. Door-left,. Door-right{position:relative;float: Left;width:50%;Height:100%;background:#f00;box-sizing:Border-box;transition:All . 5s Ease;}. Door-left{Border-right:2px solid #000;-webkit-transform-origin:0 0; }. Door-left:before,.door-right:before{content:"';position:Absolute;width:10px;Height:10px;Top:50%;Margin-top:-5px;Border-radius:50%;background:#000; }. Door-left:before{ Right:5px;}. Door-right:before{ Left:5px;}. Door-right{Border-left:2px solid #000;-webkit-transform-origin:100% 0; }. Door:hover. Door-left{-webkit-transform:Rotatey ( -90deg);transition:All . 8s Ease-out; }. Door:hover. Door-right{-webkit-transform:Rotatey (90deg);transition:All . 8s Ease-out; }</style></Head><Body><Divclass= "Door"> <Divclass= "Door-left"></Div> <Divclass= "Door-right"></Div></Div></Body></HTML>
The above code implements our requirements, the code does not need to introduce too much, just need to understand the principle of the various properties can be.
Related reading:
(1). The Border-color property can be found in the CSS3 border-color usage section.
(2). Transition can be found in the CSS3 transition attribute section.
(3).: Before can refer to the pseudo-object selector before/e::before section of CSS .
(4). Border-radius can refer to the section CSS3 achieving rounded corners .
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=18180
For more information, refer to: http://www.softwhy.com/divcss/
CSS3 implementation of the mouse suspension door closing Effect code example