实现几个div部分叠加在一起,当鼠标悬停在某个div时,那个div就在显示在最上层

it2023-09-28  76

<html> <head> <meta charset="UTF-8"> <style> html, body{ margin: 0px; width: 500px; height: 500px; } div.container{ width: 100%; height: 100%; background-color: paleturquoise; position: relative; } div.blk{ width: 150px; height: 150px; background-color: white; line-height: 150px; z-index: 0; /*最重要的一块,全部初始为0*/ position: absolute;/*设置定位方式*/ } div.blk:hover{ z-index: 100000;/*指向时 ,相应的div z-index属性设为1000000*/ } .one{ top: 100px; left: 100px; } .two{ top: 150px; left: 150px; } </style> </head> <body> <div class="container"> <div class="blk one" style="background: black;">A</div> <div class="blk two">B</div> </div> </body> </html>
最新回复(0)