我正在设计一个由3个部分组成的标题。
页面必须是流动的:min-width:940px; max-width:1200px;
头的前两个部分的大小是固定的:
left middle right
<---------><---------><----------------->
134px 183px (Fill the remaining space)
我想要根据页面的大小改变正确的部分,我会粘贴我到目前为止的东西,但我的问题是让它完全填补空白。
HTML:
<div class="main">
<div class="left"></div>
<div class="middle"></div>
<div class="right"></div>
CSS:
.main{
margin:auto;
min-width:940px;
max-width:1200px;
background-color:#000;
}
.left{
float: left;
width: 134px;
height: 191px;
background-color:#0000ff;
}
.middle{
float: left;
width: 183px;
height: 191px;
background-color:#ffff00;
}
.right{
float: left;
width: 60%;
height: 191px;
background-color:#ff0000;
}
发布于 2009-07-18 10:45:40
试试这个:
<html>
<head>
<title>Three columns</title>
<style type="text/css">
div.main { background-color: #000; }
div.left { float: left; width: 134px; height: 191px; background-color:#0000ff; }
div.middle { float: left; width: 183px; height: 191px; background-color:#ffff00; }
div.right { height: 191px; background-color: #ff0000; margin-left: 317px; }
</style>
</head>
<body>
<div class="main">
<div class="left"></div>
<div class="middle"></div>
<div class="right"></div>
</div>
</body>
</html>
发布于 2010-10-19 13:29:33
我没有足够的名气来评论,但我只是想支持之前答案的正确性。我在寻找一些稍微不同的东西: fixed-liquid-fixed,所以调整如下:
<html>
<head>
<title>Three columns</title>
<style type="text/css">
div.main { background-color: #000; }
div.left { float: left; width: 134px; height: 191px; background-color:#0000ff; }
div.middle { height: 191px; background-color: #ff0000; margin-left: 134px; margin-right: 183px;}
div.right { float: right; width: 183px; height: 191px; background-color:#ffff00; }
</style>
</head>
<body>
<div class="main">
<div class="left"></div>
<div class="right"></div>
<div class="middle"></div>
</div>
</body>
</html>
要注意的要点:-带浮动的页边距用来防止主体与边缘重叠。-在我的例子中,你需要颠倒html中div的顺序-你实际上不需要div来表示“中间”。一个没有的网站是quirksmode博客(它只是直接在"body“元素上设置页边距):http://www.quirksmode.org/blog/archives/browsers/index.html
https://stackoverflow.com/questions/1147182
复制相似问题