CSS3
过渡-盒子切换之鼠标经过背景高亮
源码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
}
.fixedtool {
width: 100px;
height: 300px;
margin: 100px auto;
}
dl {
width: 100px;
height: 100px;
margin-bottom: -1px;
background-color: #fff;
border: 1px solid #e1251b;
cursor: pointer;
transition: background-color .6s linear;
}
dl:hover {
background-color: #e1251b;
}
dl:hover dd:last-child {
display: block;
color: #fff;
}
dl dd {
color: #e1251b;
text-align: center;
line-height: 100px;
}
dl:hover dd:first-child,
dl dd:last-child {
display: none;
}
</style>
</head>
<body>
<div class="fixedtool">
<dl>
<dd>你好</dd>
<dd>世界</dd>
</dl>
<dl>
<dd>你好</dd>
<dd>世界</dd>
</dl>
<dl>
<dd>你好</dd>
<dd>世界</dd>
</dl>
</div>
<span>123</span>
</body>
</html>
运行结果:
参考资料:
[1] CSS3 过渡 | 菜鸟教程