html - 在另一个 Angular 组件中使用时如何从组件中删除动画?
问题描述
我创建了一个 Angular 组件,它为照片添加样式和一些动画。我想在另一个组件中使用相同的照片样式,但我不希望动画转移到新组件。
图片上的动画:
.pic
{
position: relative;
height: 13em;
width: 12em;
border-radius: 50%;
margin: 2em auto 0em auto;
animation-name: pop;
animation-duration: 1.5s;
animation-delay: 3.5s;
animation-fill-mode: forwards;
opacity: 0;
}
当我创建一个新组件并将该组件的选择器标签添加到新组件中时,图像会显示此动画。有没有办法可以在我创建的新组件中删除这个动画?
很多人都在建议:
.pic
{
position: relative;
height: 13em;
width: 12em;
border-radius: 50%;
margin: 2em auto 0em auto;
.anime
{
animation-name: pop;
animation-duration: 1.5s;
animation-delay: 3.5s;
animation-fill-mode: forwards;
opacity: 0;
}
}
当我将此组件的选择器标记添加<app-main-pic></app-main-pic>
到另一个组件中时,该动画类仍然存在于 .pic 上,因此图像仍然会被动画化
新组件:
<div>
<app-main-pic></app-main-pic>
</div>
<body>
</body>
解决方案
我建议您使用一种更简单的方法来执行此操作,只需编写一个没有动画的其他 CSS 类:
.pic-no-animation
{
position: relative;
height: 13em;
width: 12em;
border-radius: 50%;
margin: 2em auto 0em auto;
}
或尝试应用于[ngStyle]="{'animation-name': none}"
您的 html 标签
推荐阅读
- javascript - 导入 NPM 模块
- python-3.x - pytest函数测试多处理任务队列服务
- machine-learning - 用于实施和超参数调整的训练、开发集和测试集建议
- android - 仅阅读 firebase 中的最后 50 个帖子(Firebase 规则)
- python - 向 h5 保存名称添加一个字符时出现“OSError:无法创建文件”
- laravel - 如何从 Laravel 5.8 解决 ckeditor 中的自动源代码?
- swift - 设置音频会话类别选项的 sharedInstance 不起作用
- java - 如何添加/编译多个车把模板?
- python-3.x - tensorflow.python.framework.errors_impl.NotFoundError 添加 $ 符号
- python - 检查列表是否嵌套