微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html – 将“text-overflow:ellipsis;”应用于内部div

我有一个类似于下图的div结构.

image 1

我需要应用“文本溢出:省略号”;在较小的窗口中在这个div结构中发短信.(图2)

image 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;
	}
    

这段代码有什么问题,任何人都可以给我一个指南吗?谢谢

最佳答案
为了使元素具有溢出作为省略号,您需要在其上设置这些CSS规则:

white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 60px; #(any width would do)

这是一个jsfiddle,我在.shared-person类中添加了这些.
https://jsfiddle.net/3dukmv5q/

原文地址:https://www.jb51.cc/html/425556.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐