应用“文本溢出:省略号".到内部div [英] Apply "text-overflow: ellipsis;" to inner div

查看:29
本文介绍了应用“文本溢出:省略号".到内部div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a div structure similar to following image.

我需要应用文本溢出:省略号;"在较小的窗口中以这种div结构形式发送文字.(图片2)

I need to apply "text-overflow: ellipsis;" to text in this div structure in smaller windows.(image 2)

但是它并没有像我期望的那样适用.这是我的HTML代码

But it didn't apply as I expect. this is my HTML code

    .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:user@email.com">(user@email.com)</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>user1@email.com</li>
						</ul>
                    </div>
                </div>
            </div>
            <div class="share-icon"><img src="/resources/Image2.png" alt="Image 2" title="Image 2"></div>
        </div>
    </div>
</div>

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

What is the wrong with this code, can any one give me a guide ?? thank you

推荐答案

要使元素作为省略号溢出,您需要在其上设置以下CSS规则:

In order for an element to have overflow as elipsis you need to set these CSS rules on it:

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

这是一个jsfiddle,我已将它们添加到.shared-person类中. https://jsfiddle.net/3dukmv5q/

Here is a jsfiddle where I have added these on the .shared-person class. https://jsfiddle.net/3dukmv5q/

这篇关于应用“文本溢出:省略号".到内部div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆