javascript - 菜单打开和关闭动画
问题描述
我有问题,当我打开菜单时,我需要这样的动画:
@keyframes opening {
from {
clip-path: circle(0% at 5%, 10%)
}
to {
clip-path: circle(100%)
}
}
@keyframes closing {
from {
clip-path: circle(100%)
}
to {
clip-path: circle(0% at 5%, 10%)
}
}
在我的菜单上
.menu {
position: fixed;
height: 100vh;
width: 100vw;
top: 0;
background: #1f1f1f;
display: none;
}
菜单汉堡是按钮,我使用 javascript 打开和关闭它,同时在我的按钮上添加 .classList.toggle(class - display: block)
但关闭动画不像我想要的那样工作
我也尝试使用变换 CSS 和其他东西,它并没有像我在关键帧看到的那样给我安全的效果
我尝试在 CSS .opening {anination-name:opening, duration and etc.} 中做一个类,在我尝试使用 javascript(切换、settimeout 等)添加它之后,菜单关闭动画没有任何效果
谢谢
解决方案
Just adding basic demo code for your undestanding.
.loader {
width: 56px;
height: 56px;
border: 8px solid transparent;
border-top-color: $warning;
border-bottom-color: $warning;
border-radius: 50%;
animation: loader-rotate 1s linear infinite;
top: 50%;
margin: -28px auto 0;
}
@keyframes loader-rotate {
0% {
transform: rotate(0); }
100% {
transform: rotate(360deg); }
}
推荐阅读
- amazon-web-services - yii2-elasticsearch 2.1 不适用于 AWS elasticsearch
- kodi - xbmc/video/VideoInfoScanner:无法检索音乐视频
- spring-integration-http - Spring Integration:连接失败与错误响应代码 retryadvice()
- r - 如何将参数列表传递给R中的方法?
- c# - 从 ASP.NET 调用 Oracle 存储过程时,无法将类型为“System.Int32[]”的对象转换为类型“System.IConvertible”
- c# - 如何在c#中获取作为参数传递的表达式的字符串表示形式?
- angularjs - 混合 AngularJS/Angular 6 应用程序模块依赖问题
- postgresql - Postgres - 在交叉表查询中将空结果列转换为零
- java - 报警信号后弹出窗口 - Android
- angular - Angular 5“ng build”显示没有错误“ng build --prod”有很多错误