gpt4 book ai didi

css - 在选择框中设置选项的宽度

转载 作者:行者123 更新时间:2023-11-28 18:19:57 25 4
gpt4 key购买 nike

我有一个下拉列表,宽度不能超过 100 像素。

但是,选择框内的选项需要以 200px 显示。

有没有办法让选择框变小而选项变大?

目前选择框和选项的宽度是一样的;

到目前为止,我已经尝试了各种组合;

select.treeItem.Destination { width:130px; } 
select.treeItem.Destination option {width:auto;}

最佳答案

我认为这就是您所需要的。

这是一个 IE 6-8 特有的问题,一些 javascript 可以解决这个问题。

 <!--[if lt IE 9]>
<script>
var el;

$("select")
.each(function() {
el = $(this);
el.data("origWidth", el.outerWidth()) // IE 8 padding
})
.mouseenter(function(){
$(this).css("width", "auto");
})
.bind("blur change", function(){
el = $(this);
el.css("width", el.data("origWidth"));
});
</script>
<![endif]-->

可以在此处找到有关脚本的更多信息 - http://css-tricks.com/select-cuts-off-options-in-ie-fix/

关于css - 在选择框中设置选项的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17158540/

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