【发布时间】:2014-07-14 14:46:59
【问题描述】:
只是想知道这对于 css 是否可行,我试图有一个布局,其中左侧列具有固定宽度,右侧具有固定宽度的包含范围内的 flex 宽度。
这是图片的附件
感谢您的任何建议。
【问题讨论】:
-
你在寻找类似this的东西吗?
-
@Harry 谢谢不是真的右手边会很流畅
标签: css
只是想知道这对于 css 是否可行,我试图有一个布局,其中左侧列具有固定宽度,右侧具有固定宽度的包含范围内的 flex 宽度。
这是图片的附件
感谢您的任何建议。
【问题讨论】:
标签: css
检查this是否可以帮助您
HTML
<div class="outer">
<div class="left">Test</div>
<div class="right">Test</div>
</div>
CSS
*{margin: 0}
.outer {
max-width: 1444px;
}
.left {
float: left;
width: 200px;
height: 600px;
background: red
}
.right {
margin-left: 200px;
background: yellow;
height: 600px;
}
【讨论】:
你肯定可以用一张桌子来做。不确定是否有人有更好/替代方法。
<html>
<head>
<style>
.container { width:400px; }
.left { width:100px; background-color:red;}
.right { width:100%; background-color:yellow;}
</style>
</head>
<body>
<table class="container">
<tr>
<td class="left">left section</td>
<td class="right">right section</td>
</tr>
</table>
</body>
</html>
【讨论】:
您可以使用以下代码来实现它。基本上,我们以固定宽度浮动左侧 div,让右侧 div 占据其余部分。
HTML:
<div class='container'>
<div class='fixed-left'>abcd</div>
<div class='flexible'>12345</div>
</div>
CSS:
.container{
border: 1px solid black;
max-width: 440px;
}
.fixed-left{
float: left;
width: 200px;
border: 1px solid blue;
}
.flexible{
border: 1px solid red;
width: 100%;
}
【讨论】:
你可以使用浮点数: HTML:
<div class="left-div">This is left DIV with lots of text text text text<br />and even more text</div>
<div class="right-div">
<div class="upper">This is upper right DIV</div>
<div class="lower">This is lower right DIV</div>
</div>
CSS:
.left-div {
width: 200px;
float: left;
}
.right-div {
float: right;
}
.upper {
max-width: 100%;
}
.lower {
max-width: 1444px;
}
【讨论】: