css動畫一直是我想學的部分
有大神可以分享一下如何做到「漢堡排動畫變成X,按X再變回漢堡排」?
https://www.snapchat.com/
snapchat手機版有一樣的效果,但就是偷不走
css動畫一直是我想學的部分
有大神可以分享一下如何做到「漢堡排動畫變成X,按X再變回漢堡排」?
https://www.snapchat.com/
snapchat手機版有一樣的效果,但就是偷不走
原先看到过类似的效果,你看看这个是你想要的吗?
codepen demo
Update:
body,
html,
div {
background: #292a38;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
text-align: center;
}
svg {
width: 200px;
height: 150px;
cursor: pointer;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
path {
fill: none;
-webkit-transition: stroke-dashoffset 0.5s cubic-bezier(0.25, -0.25, 0.75, 1.25), stroke-dasharray 0.5s cubic-bezier(0.25, -0.25, 0.75, 1.25);
-moz-transition: stroke-dashoffset 0.5s cubic-bezier(0.25, -0.25, 0.75, 1.25), stroke-dasharray 0.5s cubic-bezier(0.25, -0.25, 0.75, 1.25);
-o-transition: stroke-dashoffset 0.5s cubic-bezier(0.25, -0.25, 0.75, 1.25), stroke-dasharray 0.5s cubic-bezier(0.25, -0.25, 0.75, 1.25);
-ms-transition: stroke-dashoffset 0.5s cubic-bezier(0.25, -0.25, 0.75, 1.25), stroke-dasharray 0.5s cubic-bezier(0.25, -0.25, 0.75, 1.25);
transition: stroke-dashoffset 0.5s cubic-bezier(0.25, -0.25, 0.75, 1.25), stroke-dasharray 0.5s cubic-bezier(0.25, -0.25, 0.75, 1.25);
stroke-width: 40px;
stroke-linecap: round;
stroke: #a06ba5;
stroke-dashoffset: 0px;
}
path#top,
path#bottom {
stroke-dasharray: 240px 950px;
}
path#middle {
stroke-dasharray: 240px 240px;
}
.cross path#top,
.cross path#bottom {
stroke-dashoffset: -650px;
stroke-dashoffset: -650px;
}
.cross path#middle {
stroke-dashoffset: -115px;
stroke-dasharray: 1px 220px;
}
codePen可以查看编译后的CSS和JS:
6 回答5.4k 阅读✓ 已解决
9 回答9.6k 阅读
5 回答3.8k 阅读✓ 已解决
5 回答8.1k 阅读✓ 已解决
2 回答7k 阅读
4 回答8.1k 阅读✓ 已解决
7 回答10.2k 阅读
打开网站-> f12 -> 开启响应设计模式 -> 点击这个图标观察class变化和相应的css变化 -> 直接把相应代码拷出来
通过改变
class .hamburger-expanded
和css transition
实现