星空网 > 软件开发 > 网页设计

CSS3实现的鼠标悬浮开门关门效果代码实例

CSS3实现的鼠标悬浮开门关门效果代码实例:
本章节分享一段代码实例,它利用CSS3模拟实现了简单的开门关门效果。
代码实例如下:

<!DOCTYPE html><html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>蚂蚁部落</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><div class="door"> <div class="door-left"></div> <div class="door-right"></div></div></body></html>

上面的代码实现了我们的要求,代码根本无需过多介绍,只需要明白各个属性的原理就可以了。
相关阅读:
(1).border-color属性可以参阅css3的border-color用法详解一章节。
(2).transition可以参阅CSS3的transition属性详解一章节。
(3).:before可以参阅CSS的伪对象选择符before/E::before一章节。
(4).border-radius可以参阅CSS3实现圆角效果一章节。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=18180

更多内容可以参阅:http://www.softwhy.com/divcss/




原标题:CSS3实现的鼠标悬浮开门关门效果代码实例

关键词:CSS

CSS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

Shopee上传产品:https://www.goluckyvip.com/tag/25086.html
shopee上传流程:https://www.goluckyvip.com/tag/25087.html
shopee上传商品:https://www.goluckyvip.com/tag/25088.html
shopee上架:https://www.goluckyvip.com/tag/25089.html
EORI号码:https://www.goluckyvip.com/tag/2509.html
shopee上下架:https://www.goluckyvip.com/tag/25090.html
37号文今后是否会更新?一文详解关键信息 :https://www.kjdsnews.com/a/1836441.html
探讨内地人开设香港账户的可行性 :https://www.kjdsnews.com/a/1836442.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流