Animation - 如何用偽元素創(chuàng)建顏色過(guò)渡
我們想知道如何用偽元素創(chuàng)建顏色過(guò)渡。
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div#elem {
background: red;
border: 1px solid green;
-webkit-transition: all 1s;
-moz-transition: all 1s;
}
div#elem:hover {
background: green;
border-color: red;
}
div#elem:before {
content: 'before';
background: green;
-webkit-transition: all 1s;
-moz-transition: all 1s;
}
div#elem:hover:before {
background: red;
}
div#elem:after {
content: 'after';
background: green;
-webkit-transition: all 1s;
-moz-transition: all 1s;
}
div#elem:hover:after {
background: red;
}
</style>
</head>
<body>
<div id="elem">Hello World</div>
</body>
</html>