CSS display:table-row does not expand when width is set to 100%

后端 未结 5 718
臣服心动
臣服心动 2020-12-08 01:25

I\'m having a bit of a problem. I\'m using FireFox 3.6 and have the following DOM structure:

5条回答
  •  情歌与酒
    2020-12-08 01:59

    Tested answer:

    In the .view-row css, change:

    display:table-row;
    

    to:

    display:table
    

    and get rid of "float". Everything will work as expected.

    As it has been suggested in the comments, there is no need for a wrapping table. CSS allows for omitting levels of the tree structure (in this case rows) that are implicit. The reason your code doesn't work is that "width" can only be interpreted at the table level, not at the table-row level. When you have a "table" and then "table-cell"s directly underneath, they're implicitly interpreted as sitting in a row.

    Working example:

    Type
    Name

    with css:

    .view {
      width:100%;
      display:table;
    }
    
    .view > div {
      width:50%;
      display: table-cell;
    }
    

提交回复
热议问题