【问题标题】:table cell in div is not workingdiv中的表格单元格不起作用
【发布时间】:2012-02-02 22:33:43
【问题描述】:

我在我的网站中使用表格和表格单元格。最左边的列需要从顶部开始。相反,它走到了底部。下面是该问题的链接,其中灰色 div 从最底部开始。

http://jsfiddle.net/HtAJw/9/

【问题讨论】:

    标签: css html tablecell


    【解决方案1】:

    目前尚不清楚您希望达到的最终结果。但是,通过将像素 width 添加到每个元素(其加起来小于或等于容器宽度)将阻止您看到的环绕。

    http://jsfiddle.net/HtAJw/10/

    HTML:

    <div class="parent">
        <div class="child">
            <fieldset>
                    a
            </fieldset>
        </div>
        <div class="child" >
            <div class= "newChildLeft">
                    a <br/> b<br/> b<br/> b<br/>
            </div>
            <div class= "newChildRight">
                    b<br/> b<br/> b
            </div>
       </div>
    </div>
    

    CSS:

    .parent {
        width: 100px;
        display: table;
        border: 1px solid green;
        height: 100%
    }
    .child {
        background: blue;
        display: table-cell;
        height: inherit;
        width: 50px;
    }
    .newChildLeft {
        float: left;
        width: 25px;
    }
    .newChildRight {
        float: right
        width: 25px;
    }
    .child + .child {
        background: red;
        width: 50px;
    }
    fieldset {
        height: 100%;
        background-color: #666;  
        width: 50px;
    }
    

    【讨论】:

      猜你喜欢
      • 2023-03-06
      • 2011-04-29
      • 1970-01-01
      • 2015-04-13
      • 2014-09-27
      • 2016-06-10
      • 1970-01-01
      • 1970-01-01
      • 2018-02-24
      相关资源
      最近更新 更多