【发布时间】:2017-08-12 08:40:26
【问题描述】:
我的布局由一行三列组成。
左右应与其内容一样宽。宽度的其余部分应由标题列占据。所有列的总宽度不得大于父列。
所有列都应该只有一行内容,没有换行符。
如果标题列的内容不符合约束条件,则应在末尾添加省略号。
所有这些都适用于 Chrome 和 Edge,但 IE 拒绝缩小标题列,以便这些列适合其父级的宽度。
html,
body {
width: 100%;
margin: 0;
}
.row {
display: -ms-flexbox;
display: flex;
/* https://css-tricks.com/snippets/css/a-guide-to-flexbox/ */
width: 200px;
}
[class*='cell-'] {
-ms-flex: 0 0 auto;
flex: 0 0 auto;
/* https://css-tricks.com/flexbox-truncated-text/ */
min-width: 0;
}
.cell-left {
background: red;
}
.cell-title {
white-space: nowrap;
-ms-flex: 0 1 auto;
flex: 0 1 auto;
}
.hover {
overflow-x: hidden;
text-overflow: ellipsis;
position: relative;
padding-right: 1em;
}
.chevron {
position: absolute;
right: 0;
}
.hover:hover {
background: green;
}
.cell-right {
background: yellow;
margin-left: auto;
}
<div class="row">
<div class="cell-left">Left</div>
<div class="cell-title">
<div class="hover">Pellentesque habitant morbi tristique senectus et netus et malesuada<span class="chevron">^</span></div>
</div>
<div class="cell-right">Right</div>
</div>
【问题讨论】:
标签: css flexbox internet-explorer-11 internet-explorer-10