[英]fluid content layout issue with css
I have a layout issue: 我有一个布局问题:
.sectorMenuContentPane {
float: left;
width: 25%;
}
.sectorContentPane {
float: left;
width: 75%;
}
.sectorContentPaneRight {
float: right;
width: 32%;
}
Here are my layouts using the same css: 这是我使用相同CSS的布局:
In the 3 column layout the page looks fine but in the 2 column layout its broken. 在3列布局中,页面看起来不错,但在2列布局中,页面已损坏。 How can i make it so if there isnt a sectorContentPaneRight then sectorContentPane fills the area as per my diagram?
如果没有ectoralContentPaneRight,那么我如何做到这一点,然后按我的图表填充sectorContentPane?
Also as if i need it fluid? 还好像我需要它流畅吗? Can you help me with a jsfiddle example?
您能用jsfiddle示例帮助我吗?
Tables will be your easiest solution. 表格将是您最简单的解决方案。 Here's an example using divs with
display: table
这是使用带有
display: table
div的示例
http://jsfiddle.net/9x2SC/ http://jsfiddle.net/9x2SC/
The left and right cells have a set width. 左右单元格具有设定的宽度。 The center one will fill the remaining space.
中间的一个将填充剩余的空间。 This will be your only 100% css solution.
这将是您唯一的100%CSS解决方案。 You could use Javascript to determine what to do and apply a class to the wrapper element, but this is more elegant (in my opinion.)
您可以使用Javascript来确定要执行的操作,然后将一个类应用于wrapper元素,但这更加优雅(我认为)。
css: CSS:
.wrapper {
display: table;
width: 100%;
height: 100px;
}
.sectorMenuContentPane {
display: table-cell;
width: 25%;
}
.sectorContentPane {
display: table-cell;
}
.sectorContentPaneRight {
display: table-cell;
width: 32%;
}
A simple solution: http://jsfiddle.net/JdpYP/ 一个简单的解决方案: http : //jsfiddle.net/JdpYP/
css 的CSS
.menu {
float: left;
width: 25%;
}
.slider {
float: left;
width: 32%;
}
just avoid to float the rightmost div 只是避免浮动最右边的div
Now as you know that CSS3 is being used by a lot of them.. 现在您知道CSS3已被许多人使用。
This can be done easily using CSS3. 使用CSS3可以很容易地做到这一点。
Here is how you do it.. 这是您的操作方法。
.containerOfDivs{
width:950px;
display:-webkit-box;
-webkit-box-flex: 1;
-webkit-box-orient: horizontal;
}
.sectorMenuContentPane{
width: 250px;
}
.sectorContentPane {
display:-webkit-box;
-webkit-box-flex: 1;
}
.sectorContentPaneRight {
width: 250px;
}
Not sure if this is the kind of thing you are after? 不确定这是您所追求的吗?
<div id="menu"></div>
<div id="right">
<div id="slider"></div>
<div id="content"></div>
</div>
<style>
#menu { width:25%; height:400px; border:2px solid #000; float:left; margin-right:10px; }
#slider, #content { width:48%; height:400px; border:2px solid #000; float:left; margin-right:10px; }
#right { width:74%; height:400px; float:left; }
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.