css3过渡
上次更新: 2023/01/29, 11:01:00
让元素慢慢发生变化,常跟hover使用
transition: 要过渡的属性 话费时间 运动曲线 何时开始
属性值 | 描述 |
---|---|
属性 | 宽、高、背景或者all |
花费时间 | 0.5s(必须写单位) |
运动曲线 | ease(可省略) |
何时开始 | 单位s,可以设置延迟触发时间默认0s |
::: waring 谁做过渡给谁加 :::
可用F12开发者工具查看元素及样式,可打开codepen在线编辑代码。
<html>
<div class="demo-t1"></div>
</html>
<style>
.demo-t1 {
width: 100px;
height: 100px;
margin-bottom: 50px;
background-color: red;
transition: all 1s;
}
.demo-t1:hover {
width: 300px;
}
</style>