CSS 3列浮点(2个固定,1个动态)
问题描述:
我正在设计一个由3个部分组成的头。
I'm designing a header which is made of 3 parts.
页面必须是流动的: min-width:940px; max-width:1200px;
标题的前两部分将固定大小:
The first two parts of the header will be fixed size:
left middle right
<---------><---------><----------------->
134px 183px (Fill the remaining space)
我希望正确的部分更改根据页面的大小,我将粘贴到目前为止,但我的问题是使它填补了差距完整。
I'd like the right part to change depending on the size of the page, I'll paste what I have so far but my problem is making it fill the gap completetly.
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;
}
答
>
Try this:
<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>