CSS 在 Bootstrap 3 中设置“选择”元素的高度?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18475556/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 00:08:17  来源:igfitidea点击:

Set the height of a 'select' element in Bootstrap 3?

cssselecttwitter-bootstrapheighttwitter-bootstrap-3

提问by Konstantin Rusanov

How can I set the height of a selectelement in Bootstrap 3?

如何select在 Bootstrap 3 中设置元素的高度?

Here is my code:

这是我的代码:

<select id="lst-size" name="p_size" class="col-lg-12 col-md-12 col-sm-4 col-xs-12">
  <option value="<?php echo "size1" ?>" selected="selected"><?php echo "{$rst_catalog['p_size1']}" ?></option>
  <option value="<?php echo "size2" ?>"><?php echo "{$rst_catalog['p_size2']}" ?></option>
  <option value="<?php echo "size3" ?>"><?php echo "{$rst_catalog['p_size3']}" ?></option>
  <option value="<?php echo "size4" ?>"><?php echo "{$rst_catalog['p_size4']}" ?></option>
  <option value="<?php echo "size5" ?>"><?php echo "{$rst_catalog['p_size5']}" ?></option>
  <option value="<?php echo "size6" ?>"><?php echo "{$rst_catalog['p_size6']}" ?></option>
</select>

And the live website.

现场网站

回答by edsioufi

Try to add the class .form-controlto your selectelement:

尝试将类添加.form-control到您的select元素中:

<select id="lst-size" name="p_size" class="form-control col-lg-12 col-md-12 col-sm-4 col-xs-12">

回答by techknowcrat

Quite late, but with another flavor for those who freshly bump into this:

很晚了,但对于那些刚接触到这个的人来说,还有另一种味道:

As of the time of posting this, and in the case of multiple select(which to start with, is the query that even led me here), the sizeattribute works nicely e.g size="5". See sample below;

在发布此内容时,以及在多选的情况下(首先是将我带到这里的查询),该size属性很好地工作,例如size="5". 请参阅下面的示例;

<select class="form-control" id="items" name="items" size="5" multiple>
    <option value="<?php echo "sizeX"> itemX </option>
</select>