CSS3 过渡简写属性

cssweb developmentfront end technology更新于 2025/12/10 21:00:17

过渡简写属性允许我们在一行中指定 transition-property、transition-duration、transition-timing function 和 transition-delay 作为过渡属性的值。

以下是 CSS 中过渡简写属性的代码 −

示例

<!DOCTYPE html>
<html>
<head>
<style>
.container div {
   width: 300px;
   height: 100px;
   border-radius: 1px;
   background-color: rgb(25, 0, 255);
   border: 2px solid red;
   transition: border-radius 2s ease 1s, background-color 2s ease-out 1s ;
}
.container:hover div {
   background-color: purple;
   border-radius: 50%;
}
</style>
</head>
<body>
<h1>Transition shorthand property</h1>
<div class="container">
<div></div>
</div>
<h2>Hover over the above div to change its color and its shape to oval</h2>
</body>
</html>

输出

上述代码将产生以下输出 −


相关文章


有用资源