我试图让一个元素列表与text-overflow : ellipsis
内联显示。但经过几次尝试后,我无法使文本溢出工作,它仍然制作剪辑而不是省略号
ps:可以调整此div的大小来解释text-align : center
div {
position: relative;
left: 100px;
width: 175px;
border: 1px solid black;
text-align: center;
white-space: nowrap;
overflow : hidden;
text-overflow : ellipsis;
}
ul{
margin: 0;
padding: 0;
}
li {
display: inline-block;
background-color: silver;
}

<div>
<ul>
<li>some text</li>
<li>some text that will overflow</li>
</ul>
</div>
&#13;
答案 0 :(得分:3)
此处的关键是在display:inline
和ul
上应用li
:
div {
position: relative;
left: 100px;
width: 150px;
border: 1px solid black;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
ul {
display: inline;
padding: 0;
}
li {
display: inline;
background-color: silver;
}
&#13;
<div>
<ul>
<li>some text</li>
<li>some text that will overflow</li>
</ul>
</div>
&#13;
答案 1 :(得分:1)
div {
position: relative;
left: 100px;
width: 150px;
border: 1px solid black;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
ul {
display: inline;
padding: 0;
}
li {
display: inline;
background-color: silver;
}
&#13;
<div>
<ul>
<li>some text</li>
<li>some text that will overflow</li>
</ul>
</div>
&#13;