我希望将“rightBottomPart”定位到“rightPart”的底部,并且我希望“rightPart”与“leftPart”一样高。问题是我不知道“leftPart”中内容的高度,因此我无法设置“text”的高度。(在“text”中设置高度可以解决这个问题)
现在它看起来像这样:
我希望它看起来像这样:
我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
</head>
<body style="margin: 0px 0px 0px 0px;">
<div id="headers" style="background-color: Olive; width: 300px; height: 50px;"></div>
<div id="text" style="background-color: Navy; position: relative; width: 300px;">
<div id="leftPart" style="background-color: Gray; width: 200px; float: left;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>
<div id="rightPart" style="background-color: Red; float: right;">
<div id="rightTopPart" style="background-color: Lime; position: absolute; right: 0px; top: 0px;">top</div>
<div id="rightBottomPart" style="background-color: Yellow; position: absolute; right: 0px; bottom: 0px;">bottom</div>
</div>
</div>
</body>
</html>
在我测试的其他浏览器中,它看起来只在IE7中正确。如果我删除DOCTYPE标签,它也在IE8中看起来不错,但仍然无法在Google Chrome中正常显示。
我错过了什么?
谢谢 卡尔
style
属性,而是将所有样式都包含在所谓的样式表中。使用:<link rel="stylesheet" href="css/style2.css" type="text/css" media="all" />
- Jonno_FTW