您的位置:首页 > Web前端 > JavaScript

a标签突出显示盒子非js效果

2017-08-09 18:15 155 查看
鼠标放在相应的标题上,显示对应的盒子

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
.box{
width: 300px;
height: 300px;
position: relative;
border: 1px solid #000;
}

ul li{
list-style: none;
float: left;
display: block;
}

.box1{
width: 200px;
height: 200px;
background-color: red;
position: absolute;
left: 40px;
top: 40px;
display: none;
}

.box2{
width: 200px;
height: 200px;
background-color: blue;
position: absolute;
left: 40px;
top: 40px;
display: none;
}

ul li:first-child:hover .box1{
display: block;     //鼠标移上对应li显示盒子
}
ul li:nth-child(2):hover .box2{
display: block;
}
</style>
</head>
<body>
<div class="box">
<ul>
<li>
点击显示1
<div class="box1"></div>
</li>
<li>
点击显示2
<div class="box2"></div>
</li>
</ul>
</div>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐