【发布时间】:2015-05-21 07:38:36
【问题描述】:
我有一个 50% 屏幕宽度和 100% 高度的 div。
我想在 div 的底部放置一个可以随宽度调整的图像。
设置位置我使用 position: absolute;但这删除了自动宽度:
代码:
html,
body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
#full-size {
height: 100%;
width: 100%;
overflow: hidden;
}
#aaaaa {
width: 50%;
height: 100%;
background: #0F0;
float: left;
}
.bottomImage {
width: auto !important;
width: 100%;
max-width: 100%;
position: absolute;
bottom: 0;
width: auto;
}
<div id="full-size" class="clearfix">
<div id="aaaaa">
<img class="bottomImage" src="events_bottom.png" />
</div>
</div>
有什么方法可以让图像绝对定位并调整到容器宽度?
【问题讨论】:
-
它可能无助于您尝试声明宽度 3 次...
-
这不会改变任何事情
-
感谢大家的回复!位置:相对于父母,左右为我完成。