2013-12-18 32 views

回答

22

我碰到的实际工作,如果任何人机会碰到这个问题又来这个其他的答案。

How to standardize the height of a select box between Chrome and Firefox?

基本上你改变元素的外观定义,那么你可以添加的风格吧。

.className { 
    -webkit-appearance: menulist-button; 
    height: 50px; 
} 

为我工作,但它确实改变了元素的边界。只要确保跨浏览器在更改后检查它,并确保边框样式仍然可以接受。

1

对我来说这并获得成功:

select { 
    font: inherit; 
} 
0

由于优先考虑内联样式,你可以用这种伎俩来增加你的选择列表的高度。你所要做的就是在select标签中添加内联风格。

<!-----------If you are using Bootstrap ----------> 
 

 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 

 
<body> 
 

 
<div class="container"> 
 
    <form> 
 
    <div class="form-group"> 
 
     <label for="sel1">Select list (select one):</label> 
 
     <select class="form-control" style=" height:50px;" id="sel1"> 
 
     <option>1</option> 
 
     <option>2</option> 
 
     <option>3</option> 
 
     <option>4</option> 
 
     </select> 
 
     </div> 
 
    </form> 
 
    </div> 
 
    </body> 
 

2

我希望这对你的作品

只给一个高度的选项在样式表使您可以轻松地与期权的行数计算选择字段的高度

<style>select>option{height:20px;}</style> 

并根据需要在脚本标记中添加此功能或者仅复制此文件

<script>function myFunction() { 
var x = document.getElementById("mySelect").length; 
var y = 20 * x +10; 
document.getElementById("mySelect").style.height = y+"px";}</script> 

主体部分

<body onload="myFunction()"><select id="mySelect" multiple="multiple"><option>Apple</option>option>Pear</option><option>Banana</option><option>Orange</option><option>Banana</option></select></body>