简体   繁体   中英

set z-index for show list on over the <p> text

I want to set list z-index .
when mouse over list show.
and this list show above <p> text
here is simple html and css

<style>
ul li{
    display:none;
}
ul:hover li{
    display:block;
    z-index:-1;
}
</style>

<ul><h3>This is LIST</h3>
<li>back</li>
<li>forword</li>
<li>click</li>
</ul>
<p>list show above this text.</p>

with this CSS when mouse over the this is list then its wrapped.
but I want when mouse over at This is LIST then show there list over the <p> text. here is jsfiddle how its possible.

Z-index仅适用于位置为“相对”,“固定”或“绝对”而不是“静态”(默认)的元素。

Sounds like what you want is to "preserve" the place for list items even when they are hidden.

For this purpose, use visibility CSS attribute instead of display :

ul li {
    visibility: hidden;
}

ul:hover li {
    visibility: visible;
}

Updated fiddle .

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