我试图弄清楚如何创建一个显示两列的布局,一列在左侧,一列在右侧。我很喜欢指定左列的宽度,但由于边距和填充,我真的不想指定右列的宽度,而是让浏览器来决定。
我找不到任何这样做的例子,人们似乎总是给所有列一个固定的宽度。这是一些重现该问题的示例代码:
<html>
<head>
<style type="text/css">
#left, #right {
border: solid 1px #000000;
}
#left {
float: left;
width: 10%;
}
#right {
float: left;
}
</style>
</head>
<body>
<div id="left">I'm left</div>
<div id="right">
<p>I'm right.</p>
<p>There is a bit more text here.</p>
<p>Let's assume for a moment, that there is so much text here,
that it cannot possibly fit on one line on any kind of monitor.
For this purpose, I have to write a bit of nonsense, but there is
always enough nonsense for this kind of task in the world.
I could always ask a politician, I'm sure there isn't even a single
cinema canvas in the world that could display such nonsense in a
single line.
</div>
</body>
</html>
请注意,如果我要删除特别长的段落,右栏将足够小以适合同一行并且它会起作用。
有没有办法让右列占用剩余空间?