我想要一个具有两个右对齐列的布局。所以,我创建了三个申报单(两列和一个包装):右对齐的双列布局会丢失水平滚动条
<div id="wrapper">
<div id="left">
First column
</div>
<div id="right">
Second column
</div>
</div>
我浮在left
DIV左,right
DIV权,并设置正确的宽度为所有三个div的:
#wrapper{
width:30em;
}
#left{
float:left;
width:10em;
}
#right{
float:right;
width:20em;
}
这一切看起来如预期...
Without floating the div http://img690.imageshack.us/img690/5844/rightrightalign.png
..但后来我漂浮在wrapper
DIV向右如果需要的话,并没有WebKit的,也没有Firefox的显示水平滚动条:
Without the right align http://img690.imageshack.us/img690/8559/withoutrightalign.png
同样的情况,如果我使用position: absolute; right:0
完整的示例HTML文档:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<style type="text/css" media="screen">
#wrapper{
width:30em;
float:right; /* The problem line */}
#left{
float:left;
width:10em;
background: green;}
#right{
float:right;
width:20em;
background: red;}
</style>
</head>
<body>
<div id="wrapper">
<div id="left">Left</div>
<div id="right">Right</div>
</div>
</body>
</html>
有没有办法让一个右对齐的双列布局,不会丢失水平滚动条?
这是*怪异*!我在Windows 7的本地FF上进行了测试。我删除了文档类型,并将“overflow:auto”添加到了主体中,但都无济于事。我正在删除我的答案,所以这个问题吸引了更多的关注。真的有兴趣这是为什么。 – 2010-02-08 01:04:13