css - 并排 float 两个div

标签 css internet-explorer-7 css-float internet-explorer-6

无论屏幕大小如何,我都试图并排 float 两个 div。目前在 IE 7 中,如果我调整窗口大小,一个 div 会下降到另一个下方。我认为这是因为 div2 包含一个表格,一旦窗口边缘碰到表格,它就会下降到 div1 下面。

我目前在 IE9 和 Firefox 中工作,但它需要在 IE6+7 中工作。我试过这个解决方案 CSS floats - how do I keep them on one line?但它似乎没有帮助。我再次认为这可能是由于这些 div 中的内容所致。 如何复制?

代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>

<style>
  #wrapper { 
    min-width:510px; 
    width: auto !important; 
    width: 510px; 
    border: 1px solid red; }

  #div1 {
    float:left;
    color:blue;
    width:500px;
    border: 1px dashed purple; 
    height: 400px;}

  #div2 {
    margin-left:505px;
    border:1px dashed purple;}

  #div2 table{border: 1px dotted green;}

</style>
</head>
<body>
  <div id="wrapper">
    <div id="div1" >
      Sometimes I contain a table and sometimes I contain an object. Bother of which displays a chart
    </div>    
    <div id="div2">    
       <table>
        <tr>
         <td> I am normally a report
           asdfasdfads
           dsafasdfasdfasdfasdfadsfasdfasdadfadsfadfsdfasdfsdffGreat Thanks, today has been quiet hot but somehow a bit cooler than this time last year. 
         </td>
       <td></td>
       </tr>
      </table>
    </div>
  </div>
</body>
</html>

可以在这里找到一个实例 http://jsbin.com/awijew/11

最佳答案

去掉margin-left: 505px;在 div2 上

关于css - 并排 float 两个div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6937887/

相关文章:

css - 如何通过CSS在/div容器中添加填充空间?

css - 带有指针事件和鼠标滚动的 Chrome 错误?

html - 调整窗口大小时输入向左移动

javascript - ie6和ie7中简单的javascript字符串问题

html - IE9 float 溢出 :Hidden and Table Width 100% Not Displaying Properly

CSS 清除 float

javascript - Ajax 成功函数动画

css - ie7 中奇怪的 css 行为

html - 如何使标准模式和怪异模式一起工作?

css - float 元素和 div 在 IE 中显示不同