Html div 容器上的图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7064779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 10:04:53  来源:igfitidea点击:

Image over div-container

csshtmlimageoverlap

提问by shub

How can I overlap the message strip with the div?

如何将消息条与 div 重叠?

Image over div-container

div 容器上的图像

The position of the div "nav" must be fixed.

div "nav" 的位置必须是固定的。

<img src="images/diagonal_corner_message_strip.png" id="copyright" /><div id="nav">
  <ul>
    <li><a class="top" href="#top"><span></span></a></li>
    <li><a class="bottom" href="#bottom"><span></span></a></li>
    <li><a>List</a></li>
    <li><a>Create</a></li>
  </ul>
 </div>

#nav {
    padding: 6px 0;
    border-bottom:1px solid #ddd;
    position:fixed;
    width:100%;
    top:0px;
    left:0px;
    right:0px;
    margin:0;
    background:#fff url(../images/navigation/nav.png) repeat-x center left;
    z-index:999999;
}

img#copyright {
    position:absolute;
    top:0px;
    left:0px;
    right:0px;
    float:left;
}

Thanks a lot!

非常感谢!

回答by Kokos

The z-indexof #navis set to 999999.

z-index#nav设置为999999

The z-indexof img#copyrightis not set.

z-indeximg#copyright未设置。

The z-indexdefines the order in which elements will be shown, with the highest value being shown on top. The solution to your problem is easy, give img#copyrighta higher z-indexthan #nav.

所述z-index的元件,其中将示出,具有最高值定义的顺序被显示在顶部。你的问题的解决方案是容易的,给img#copyright一个较高的z-index#nav