gpt4 book ai didi

html - 在 Bootstrap 中截断长链接

转载 作者:太空狗 更新时间:2023-10-29 15:44:57 25 4
gpt4 key购买 nike

我正在使用 Bootstrap 3.1 设计一个页面,如果 HTML 链接的长度太长,它就会溢出并在移动版本中创建水平滚动。有没有办法截断它并用省略号替换它?

例子:

enter image description here

我需要的是,它应该在边界之前被截断,而不是向外延伸。知道怎么做吗?

最佳答案

您需要确保容器具有overflow: hidden 以防止文本流出边界并给它text-overflow: ellipsis 以提供链接省略号。

.box {
background: #f99;
border: 1px solid #c66;
width: 100px;
padding: 7px;
margin-bottom: 15px;
}

.nowrap {
white-space: nowrap;
}


.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
}
<div class="box">
<span class="nowrap">A really long piece of text</span>
</div>

<div class="box ellipsis">
<span class="nowrap">A really long piece of text</span>
</div>

关于html - 在 Bootstrap 中截断长链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28126347/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com