我是靠谱客的博主 多情老师,这篇文章主要介绍使用css过渡有哪些触发方式,现在分享给大家,希望可以做个参考。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

第一种: 通过伪类元素触发

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
<style> .box{ width: 100px; height: 100px; background-color: blueviolet; transition: width 1s linear .5s; } .box:hover{ width: 400px; } </style> <p class="box"> </p>
登录后复制

第二种: 通过JS触发

通过js添加必须有一定的延迟(延迟去掉无效果)来改变元素的样式

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<style> .box{ width: 100px; height: 100px; background-color: blueviolet; transition: width 1s linear .5s; } .box1{ width: 400px; }</style> <p class="box"> </p> <scrpit> setTimeout(() => { let element = document.getElementsByClassName('box')[0]; element.classList.add('box1') }, 1) </scrpit>
登录后复制

推荐学习:css视频教程

以上就是使用css过渡有哪些触发方式的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是多情老师最近收集整理的关于使用css过渡有哪些触发方式的全部内容,更多相关使用css过渡有哪些触发方式内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(92)

评论列表共有 0 条评论

立即
投稿
返回
顶部