html - float 权利问题

标签 html css internet-explorer css-float

我想让一个固定大小的div向右浮动,其余空间需要保留。 我以流畅的方式完成了这项工作:

HTML:

<div class="container">
<div id="rightCntr">
</div>
<div id="leftCntr">
</div>
</div>

CSS:

#leftCntr { 
float: none; /* not needed, just for clarification */
background: #e8f6fe;
/* the next props are meant to keep this block independent from the other floated one */
width: auto;
overflow: hidden; 
}

#rightCntr { float: right; width: 213px;}

这在 Firefox 和 Chrome 中运行良好,但在 IE8 中就完全出错了。 Example

最佳答案

示例 jsBin:http://jsbin.com/ixebuf/1/ (在 IE8、Fx 上测试) (背景放置用于测试目的)

.container {
  width: 100%;
  overflow: hidden;
}
#rightCntr {
  float: right;
  width: 213px;
  background: gray;
}
#leftCntr {
   margin-right: 213px; 
   background: yellow;
}

关于html - float 权利问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14354336/

相关文章:

html - Div 不考虑高度百分比

javascript - 为什么 element.style 在 JS 中总是返回空?

javascript - 单击事件在 IE 中打开错误的对话框

php - 即 : input type ="file" multiple

jQuery Marquee 滚动文本在 Bootstrap Modal 中不起作用

javascript - 动态输入不起作用

javascript - 移动设备的特定 css 但不基于屏幕分辨率

html - 当第一个 `<td>` 的高度大于第二个 `<td>` 时,如何将第二个 `<td>` 中的元素对齐到左上角

javascript - 尝试从输入中获取文件在 IE8 中返回对象错误

php - 将 PHP 变量作为 Ajax 传递回原始页面上的 JavaScript 变量