I have a div structure similar to following image.
我需要应用“文本溢出:省略号;”在较小的窗口中使用此 div 结构中的文本。(图 2)
但它并没有像我预期的那样适用。这是我的 HTML 代码
.header {
height: 60px;
width: 100%;
}
.header > .header_middle {
margin: 0 auto;
width: 100%;
}
.header > .header_middle.share-file-header > .caption {
float: left !important;
line-height: 60px;
overflow: hidden;
padding-right: 0 !important;
text-overflow: ellipsis;
white-space: nowrap;
padding: 0 30px;
}
.header > .header_middle.share-file-header .settings {
line-height: inherit;
padding: 0 15px 0 0;
float: right;
height: 60px;
position: relative;
}
.shared-person-detail-wrapper {
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
line-height: inherit;
}
.settings .share-files-msg, .settings .shared-person {
display: block;
font-size: 14px;
text-overflow: ellipsis;
}
.settings .more-persons-wraper {
display: inline-block;
position: relative;
}
<div class="header">
<div class="header_middle share-file-header">
<div class="caption">
<p>
<a href="/">
<img src="/resources/Image1.png" alt="Image 1" title="Image 1">
</a>
</p>
</div>
<div class="settings">
<div class="shared-person-detail-wrapper">
<div class="shared-person">
User Name <a href="mailto:[email protected] /cdn-cgi/l/email-protection">([email protected] /cdn-cgi/l/email-protection)</a>
</div>
<div class="share-files-msg">
has shared file(s) with you
<div class="more-persons-wraper">and some <a href="#" data-toggle="dropdown" id="more">more</a> people.
<ul class="dropdown-menu pull-right" id="more-persons">
<li>[email protected] /cdn-cgi/l/email-protection</li>
</ul>
</div>
</div>
</div>
<div class="share-icon"><img src="/resources/Image2.png" alt="Image 2" title="Image 2"></div>
</div>
</div>
</div>
这段代码有什么问题,有人可以给我指导吗?谢谢
为了使元素溢出作为省略号,您需要在其上设置以下 CSS 规则:
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 60px; #(any width would do)
这是一个 jsfiddle,我在 .shared-person 类中添加了这些内容。https://jsfiddle.net/3dukmv5q/ https://jsfiddle.net/3dukmv5q/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)