Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一系列 ap div 像一堆乱七八糟的照片一样堆叠起来。我希望访问者能够单击该堆栈中的照片,并且该照片位于堆栈顶部。这是我为每个 ap div 所拥有的:
#apDiv6 { position:absolute; width:180px; height:172px; z-index:1; top: 90px; left: 377px;}
我想知道我可以添加什么代码来更改 ap div 中单击图像的 z 索引。谢谢
您可以将当前选定 div 的 z-index 更改为更高的值:
var z = 10; //Declare it as global variable function ShowDiv() { document.getElementById(id).style.display = "block"; document.getElementById(id).style.zIndex = z; z++; }