我使用的 div 内部有 2 个元素,我想将第一个元素垂直对齐到 div 的顶部,将第二个元素垂直对齐。 div 是页面的右侧部分,等于主要内容的高度。
#right {
float:right;
width: 19%;
background:#FF3300;
margin-left:2px;
padding-bottom: 100%;
margin-bottom: -100%;
}
#right .top {
display:block;
background-color:#CCCCCC;
}
#right .bottom {
bottom:0px;
display:block;
background-color:#FFCCFF;
height:60px;
}
HTML:
<div id="right">
<span class="top">Top element</span>
<span class="bottom"><img src="images/logo_footer1.gif" width="57" height="57" align="left" class="img"> <img src="images/logo_footer2.gif" width="57" height="57" align="right" class="img"></span>
</div>
我希望正确的 div 是这样的:替代文本 http://christianruado.comuf.com/element.png http://christianruado.comuf.com/element.png
如果您指定position: relative
for #right
, 进而position: absolute
对于两个内部元素,您应该能够使用 top/left/bottom/right 属性来达到您想要的效果。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)