【发布时间】:2015-07-16 22:06:53
【问题描述】:
Div 包含一个背景图像 - 在运行时提供(因此不能使用 img 作为背景),图像顶部是一个按钮。第一种方法是使用绝对定位将按钮放置在图像上方。这一直有效,直到页面调整大小并且 div 调整大小。
http://jsfiddle.net/ubWuX/330/
第一个 div 是我想要的,2 和 3 显示调整大小后会发生什么
div 图像也是可选的,所以如果没有给出,div 应该有一个 bg-color
#img_container {
position:relative;
display:inline-block;
text-align:center;
border:1px solid red;
background-color:gray;
}
.button {
position:absolute;
bottom:78px;
right:40px;
width:100px;
height:30px;
}
.resize {
width:300px;
height:200px;
}
<div id="img_container">
<img src="http://jsfiddle.net/img/initializing.png"/>
<button class="button"> click here </button>
</div>
<br>
<div class="resize" id="img_container">
<img src="http://jsfiddle.net/img/initializing.png"/>
<button class="button"> click here </button>
</div>
<br>
<div class="resize" id="img_container">
<button class="button"> click here </button>
</div>
【问题讨论】:
标签: html css responsive-design