应用“文本溢出:省略号;”到内部 div

2024-03-21

I have a div structure similar to following image. image 1

我需要应用“文本溢出:省略号;”在较小的窗口中使用此 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(使用前将#替换为@)

应用“文本溢出:省略号;”到内部 div 的相关文章

  • IE 位置问题:绝对

    我有这段代码 它在 Firefox 中运行得很好 但在资源管理器上会向右射击 这段代码有什么我看不到的问题吗 感谢您的帮助 div a href http www mysite com img src images sponsor png
  • CSS“内容”不起作用

    我想通过 CSS 添加该段落的文本 而不是在 HTML 中 因为它会随着网站的响应能力而变化 现在我无法让它工作 我想知道CSS是否有问题 另外 这是唯一可以做到的方法 使用纯 HTML 和 CSS 还是有另一种方法来定位文本并根据每个分辨
  • 使用 CSS 的样式选择选项

    我正在尝试使用 CSS 设置选择选项列表的样式 我希望列表的时间之间有更多的填充 因为它们似乎被压在一起 我尝试向选项元素添加填充 但这似乎不起作用 有任何想法吗 这是我的代码 HTML
  • html 可嵌入 flash wav 播放器

    我需要一个可在 IE FF 和 Chrome 中播放 wav 文件的嵌入式音频播放器 目前无法转换为 mp3 或任何其他格式 该播放器应该非常简单 只有一个播放 暂停按钮 也许还有一个时间轴栏 用户可以单击该时间轴栏来转到音频的特定部分 还
  • 如何在FireFox中检查用户访问麦克风的权限是否被拒绝

    有没有办法查明用户是否拒绝或允许媒体设备的权限 例如 Firefox 中的麦克风 摄像头 在 Chrome 中 我可以使用 navigator permissions query 检查这一点 但在 Firefox 中会失败并出现 TypeE
  • 具有自定义设计的 ASP.NET 复选框

    有没有办法改变asp net复选框的ui样式 我试过这个 cabeceraCheckBoxNormal background url ig res Default images ig checkbox off gif no repeat c
  • Selenium driver.page_source() 仅提取部分 HTML DOM

    我有一个网页 当我右键单击它然后查看页面源时 我得到 SECTION A 但是当我点击它然后检查时 我得到了更长的输出 我尝试使用 JS 获取页面源 但同样的问题 我得到了输出SECTION A 我怎样才能解决这个问题 注意 我正在寻找通用
  • 使用条件注释的目的