【发布时间】:2012-05-14 23:18:40
【问题描述】:
请参考小提琴:http://jsfiddle.net/ukzKT/8/。
我希望内部 div #this-bottom 保持在底部,但它的宽度应该与其中的任何其他 div 一样。即它应该保持在父 div #top 的填充区域内。
CSS
#top{
width:300px;
position:relative;
padding:20px;
border:1px solid #222;
}
#this-bottom{
position:absolute;
bottom:0;
border:1px solid #333;
right: 18px;
left: 20px;
}
#other{
width:100%;
border:1px solid #333;
}
HTML
<div id='top'>
<div id='other'>
This is 1 <br />
THis is 2 <br />
This is 3 <br />
</div>
<div id='this-bottom'>
This should be bottom
</div>
</div>
【问题讨论】:
-
当您没有定义 CSS 时,为什么会出现这种行为?
-
@Diodeus 对不起(错误的小提琴)。现在检查。
-
@ShahalTharique 你的css没有问题,超过父宽度是正常的,因为你使用的是
padding:20; -
@mgraph 是的,我知道.. 任何解决方法?