gpt4 book ai didi

html - 选择多个文本溢出?

转载 作者:行者123 更新时间:2023-11-28 00:11:28 24 4
gpt4 key购买 nike

我正在尝试对具有多个选择的选项应用文本溢出。但是,我似乎无法触摸选项文本。

这是我的 HTML:

 <select id="multiselect" multiple="" size="6">

<option value="123456780123456780123456780123456780123456780123456780" selected="selected">123456780123456780123456780123456780123456780123456780</option>
<option value="other" selected="selected">other</option>
</select>

这是我的 CSS:

#multiselect {
width: 222px;
border-top: 2px solid #ccc;
float: none;
background: #fff;
outline: none;
margin-right: 0;
margin-left: 5px;
border-radius: 0;
margin-bottom: 11px;
overflow: hidden;
text-overflow: ellipsis;
}

#multiselect option {
overflow: hidden;
text-overflow: ellipsis;
white-space:nowrap;
width:222px;
}

我知道文本溢出在它应该(我认为)只应用于选项时会重复,但我想证明它在任何一种解决方案中都不起作用。

有没有人有这方面的经验?

最佳答案

不幸的是,我找不到纯 CSS 的解决方案,所以我从 this post 中获得了一些灵感。 (不是选择的答案,而是另一个,它更准确并且处理非间隔答案)并提出这个 JS Loop 实现目标:

$('#multiselect option').each( function() {
//Manually make the ellipsis, since CSS3 gets weird with select multiple.
if (dictionary_length($(this).text()) > 30) {
$(this).text($.trim($(this).text()).substring(0, 28).trim(this) + "...");
}
});

关于html - 选择多个文本溢出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14936482/

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