我不知道为什么这个简单的CSS不能工作…
.app a { 高度:18 px; 宽度:140 px; 填充:0; 溢出:隐藏; 位置:相对; Margin: 0 5px 0 5px; text-align:中心; 文字修饰:没有; 文本溢出:省略; 空白:nowrap;} 颜色:# 000; } < div class = "应用" > <a href="">Test Test Test Test Test Test Test</a> . < / div >
应该在第四次“测试”前后切断
我不知道为什么这个简单的CSS不能工作…
.app a { 高度:18 px; 宽度:140 px; 填充:0; 溢出:隐藏; 位置:相对; Margin: 0 5px 0 5px; text-align:中心; 文字修饰:没有; 文本溢出:省略; 空白:nowrap;} 颜色:# 000; } < div class = "应用" > <a href="">Test Test Test Test Test Test Test</a> . < / div >
应该在第四次“测试”前后切断
当前回答
我一直有这个问题,我想要一个解决方案,可以很容易地与动态宽度工作。解决方案使用css网格。 下面是代码的样子:
.parent { 显示:网格; Grid-template-columns: auto 1fr; } .dynamic-width-child { 空白:nowrap;} 文本溢出:省略; 溢出:隐藏; } .fixed-width-child { 空白:nowrap;} } < div class = "父" > < div class = " dynamic-width-child”> iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii asdfhlhlafh; lshd flhsd; lhfaaaaaaaaaaaaaaaaaaaa < / div > < div class = " fixed-width-child”>为什么?zed < / div > < / div >
其他回答
添加显示:块;或显示:inline-block;#User_Apps_Content .DLD_App
demo
你也可以添加float:left;在这个选择器内部:
#User_Apps_Content .DLD_App a
我一直有这个问题,我想要一个解决方案,可以很容易地与动态宽度工作。解决方案使用css网格。 下面是代码的样子:
.parent { 显示:网格; Grid-template-columns: auto 1fr; } .dynamic-width-child { 空白:nowrap;} 文本溢出:省略; 溢出:隐藏; } .fixed-width-child { 空白:nowrap;} } < div class = "父" > < div class = " dynamic-width-child”> iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii asdfhlhlafh; lshd flhsd; lhfaaaaaaaaaaaaaaaaaaaa < / div > < div class = " fixed-width-child”>为什么?zed < / div > < / div >
包括info后面写的四行,以便省略号起作用
.app a
{
color: #fff;
font: bold 15px/18px Arial;
height: 18px;
margin: 0 5px 0 5px;
padding: 0;
position: relative;
text-align: center;
text-decoration: none;
width: 140px;
/*
Note: The Below 4 Lines are necessary for ellipsis to work.
*/
display: block;/* Change it as per your requirement. */
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
只需添加包含该段落的div即可
white-space: nowrap
width: 50px;
overflow: hidden;
text-overflow: ellipsis;
border: 1px solid #000000;