我想将一个包含 addsense 脚本内容的 DIV 放在我用作横幅的 img 之上。
我在 div 中有 img 标签。然后我将谷歌脚本放在下面的 div 中并为其设置此样式
style="float:right;left:250;z-index:2"
添加显示在 img 下方,而不是其上方。有什么想法吗??
最佳答案
你想用 absolute
定位第二个 div:
相关代码:
img {
border: 2px solid black;
}
#container {
position: relative;
}
#example {
position: absolute;
top: 10px;
left: 10px;
padding: 5px;
background-color: white;
border: 2px solid red;
}
<div id="container">
<img src="https://placekitten.com/g/193/129">
<div id="example">This is my div</div>
</div>
关于html - 将 div 置于图像之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4218204/