2017-07-06 71 views
2

我正在用scss构建一个div表格作为表格。我已将它转换为css用于演示。
第一个和最后一列固定为90px和30px。
包围的链接是表格行SCSS:固定和流体表格单元

| 90px |流体sdfsdfsdfsdfd sd ... | 30px |
| 90px |液体asdasdasd(空白)| 30px |

表格宽度应为100%。 流体部分的宽度应该自动获得100% - 30PX - 90像素

我的计划是自动获得流体宽度取决于固定宽度而不

width: calc(100% - 30px - 90px) 

该表不应该被拉伸大于100%,流体容器的内容应该是好的省略号标签。

我的样式表中是否有错误?

div.menu { 
 
    display: table; 
 
    border-collapse: collapse; 
 
    width: 100%; 
 
} 
 
div.menu .head { 
 
    display: table-row; 
 
    height: 34px; 
 
    line-height: 34px; 
 
} 
 
div.menu .head div { 
 
    padding: 0 5px; 
 
    display: table-cell; 
 
} 
 
div.menu .head div:first-of-type { 
 
    width: 90px; 
 
} 
 
div.menu .head div:last-of-type { 
 
    width: 30px; 
 
} 
 
div.menu a { 
 
    height: 60px; 
 
    line-height: 60px; 
 
    display: table-row; 
 
    border-top: 1px solid #f2f2f2; 
 
    text-decoration: none !important; 
 
} 
 
div.menu a div { 
 
    display: table-cell; 
 
    padding: 0 5px; 
 
    white-space: nowrap; 
 
    overflow: hidden; 
 
    text-overflow: ellipsis; 
 
} 
 
div.menu a div:first-of-type { 
 
    width: 90px; 
 
} 
 
div.menu a div:last-of-type { 
 
    width: 30px; 
 
} 
 
div.menu a:last-of-type { 
 
    border-bottom: 1px solid #f2f2f2; 
 
}
<div class="menu"> 
 
    <div class="head"> 
 
    <div>Text</div> 
 
    <div>Name</div> 
 
    <div></div> 
 
    </div> 
 
    <a href="#"> 
 
    <div>Info</div> 
 
    <div>Name of the item</div> 
 
    <div>icon</div> 
 
    </a> 
 
    <a href="#"> 
 
    <div>Info</div> 
 
    <div>Name of another item</div> 
 
    <div>icon</div> 
 
    </a> 
 
    <a href="#"> 
 
    <div>Info</div> 
 
    <div>This is a very long name, and it should not be greater than the page, and i want to see the icon. But it's not working.</div> 
 
    <div>icon</div> 
 
    </a> 
 
</div>

回答