核心提示:鼠标放在相应的标题上,显示对应的盒子!DOCTYPE htmlhtmlheadmeta charset=utf-8title/titlestyle.box{width: 300px;height: 3...
鼠标放在相应的标题上,显示对应的盒子
<!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> <p class="box"> <ul> <li> 点击显示1 <p class="box1"></p> </li> <li> 点击显示2 <p class="box2"></p> </li> </ul> </p> </body> </html>