在图片上方放置一个div [英] position a div on top of an image
本文介绍了在图片上方放置一个div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将带有addsense脚本内容的DIV放在我用作横幅的img之上。
I want position a DIV with the content of an addsense script on top of a img that I use as a banner.
我在div内有img标签。然后我将Google脚本放入以下div并将其设置为此样式
I have the img tag inside a div. then I put the google script inside a following div and set this style to it
style="float:right;left:250;z-index:2"
添加项显示在img下方,而不是其上方。有什么想法吗?
The add is shown below the img and not on top of it. Any ideas??
推荐答案
您要使用绝对
:
相关代码:
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>
这篇关于在图片上方放置一个div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文