多项选择-大小属性无法应用 [英] Multiple select - size attribute cannot be applied
问题描述
我选择了<select multiple="multiple">..</select>
,并且在某些无法编辑的样式表中也有select{heigth: 30px;}
.现在,我的多选具有1行高度-无法应用大小"属性.我该如何解决这个问题?
I have <select multiple="multiple">..</select>
select and I also have select{heigth: 30px;}
in some stylesheet that I cannot edit. Now my multiple select have 1-row heigth - "size" attribute cannot be applied. How can I solve the problem?
推荐答案
首先,我假设您正在使用height
属性,而不是拼写错误的 heigth
财产.有两种方法可以解决此问题.
第一个(我不建议这样做)是将样式简单地附加到HTML元素,如下所示:
Well, first off - I'm assuming that you're using the height
property, not the misspelled heigth
property. There's two ways you could solve this.
The first (which I don't recommend) is by simply appending the style to the HTML element, like below:
<select multiple="multiple" style="height:100px">..</select>
或者,我的建议是制作第二个样式表,该样式表使用以下属性,包括跟随属性值的!important":
Or, instead, my suggestion would be making a second style sheet, that uses the following property, including the "!important", which follows the attribute value:
select {
height: 100px !important;
}
这样做将覆盖原始样式并替换它.这不是可以用来覆盖它的唯一方法-您可以在此处阅读CSS特异性.
Doing it like such will override the original style, and replace it. This isn't the only method that you can use to override it - you can read here on CSS specificity.
这篇关于多项选择-大小属性无法应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!