关闭边栏(ESC)打开边栏(ESC)
如本站侧边栏关注我相关按钮的过渡动画,感觉还是挺好看的,分享如下:
一、相关结构与CSS:
1 2 3 4 5 |
<div class="diy-gz"> <a href=""><span>我</span></a> <a href=""><span>你</span></a> </div> |
二、相关css:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
.diy-gz a { position: relative; width: 40px; height: 40px; line-height: 40px; display: inline-block; margin: 0 auto; border-radius: 50%; color: #999!important; text-align: center; transition: all .5s; outline: none; background: #ddd; } .diy-gz a::before { content: ""; position: absolute; z-index: 0; left: 0; top: 0; width: 40px; height: 40px; border-radius: 50%; opacity: 0; -webkit-transform: scale(0, 0); transform: scale(0, 0); transition: all .5s cubic-bezier(.3, 0, 0, 1.3) 0s; } .diy-gz a:nth-child(1):before { background: #db214c; } .diy-gz a:nth-child(2):before { background: #22214c; } .diy-gz a:hover:before { opacity: 1; -webkit-transform: scale(1, 1); transform: scale(1, 1) } .diy-gz a span{position: relative;z-index: 2;} |
三、效果如下: