简体   繁体   中英

How to change z-index only this id elements?

How to change z-index only this id elements ?

When i use this code ,all id in my page will change z-index.

I want to change z-index only id = link-box , love-box , love-box_inner

How can i do that ?

document.getElementById("link-box").style.zIndex="99999";
document.getElementById("love-box").style.zIndex="99999";
document.getElementById("love-box_inner").style.zIndex="999999";

My guess is that your three elements, #link-box , #love-box and love-box_inner have the default position of static , and as result, z-index , though set, has no effect.

In addition, you need to set position: relative on the three relevant elements.

set firs style position relativ or absolute and new add this zIndex for example

document.getElementById("link-box").style.position="relative";
document.getElementById("love-box").style.position="relative";
document.getElementById("love-box_inner").style.position="relative";

document.getElementById("link-box").style.zIndex="99999";
document.getElementById("love-box").style.zIndex="99999";
document.getElementById("love-box_inner").style.zIndex="999999";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM