2017-07-06 68 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>

回答