伪类hover 触碰特效
伪类hover特效作用在本体元素身上时候使用方式
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
.file-btn {
float: left;
width: 100px;
height: 50px;
border: 2px solid blanchedalmond;
background-color: antiquewhite;
margin: 0;
padding: 0;
line-height: 50px;
text-align: center;
cursor: pointer;
}
.file-btn:hover {
background-color: sandybrown;
border: 2px solid sienna;
}
</style>
</head>
<body>
<div class="file-btn">伪类hover
</div>
</body>
</html>
伪类hover特效作用在子元素身上时候使用方式
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
.file-btn {
float: left;
width: 100px;
height: 50px;
border: 2px solid blanchedalmond;
background-color: antiquewhite;
margin: 0;
padding: 0;
line-height: 50px;
text-align: center;
cursor: pointer;
position: relative;
}
.file-btn .file-btn-son {
position: absolute;
width: 100px;
height: 50px;
border: 2px solid sienna;
background-color: sandybrown;
margin: 0;
padding: 0;
line-height: 50px;
text-align: center;
cursor: pointer;
display: none;
top: 50px;
left: -2px;
}
.file-btn:hover .file-btn-son{
display: block;
}
</style>
</head>
<body>
<div class="file-btn">伪类hover
<div class="file-btn-son">
我是子元素
</div>
</div>
</body>
</html>
本文来自博客园,作者:觉远,转载请注明原文链接:https://www.cnblogs.com/imlaoxie/p/18603564

浙公网安备 33010602011771号