jquery - 由于选择元素的大小,Bootstrap 选择选项被隐藏

标签 jquery html css angularjs twitter-bootstrap

我有一个填充的 Bootstrap 选择标签,看起来像:

enter image description here

完美运行,显示所有要选择的元素。

但是 当我使用 css 降低选择的高度时,它显示如下:

enter image description here选项正在填充但隐藏起来,只是因为我添加了这个 CSS:

#selectOption {
    font-size: 12px;
    height: 20px;
}

所以请指导我如何强制选项以这个高度显示?

Providing full code for select option and controller:

选择选项

<div class="col-sm-3">
    <fieldset class="form-group">
        <label id="fieldTitle">Appointment Type</label>
        <select id="selectOption" ng-model="frieghtSale.apptType" ng-
          options="type.code as type.value for type in appointmentTypes" 
          class="form-control input-sm" required data-error="Please select 
          appointment type">
          <option value="" disabled>Select Appointment Type</option>
        </select>
        <div class="help-block with-errors"> {{freightSale.apptType}} </div>
    </fieldset>
</div>

AngularJS Controller

$scope.populateAppointmentTypes = function() {
        $.ajax({
            url: someURL/common/dropdown?typ=ApptType',
            dataType: 'JSON',
            success: function(data) {
                $scope.appointmentTypes = data;
            }, error: function(error) {
                console.log( "Could not populate appointment types: " + error );
            }
        });
    }

最佳答案

我想这是因为默认情况下 bootstrap 在选择时有一个填充。

这样填充会将您的文本推到底部,这样它就不会显示。

只需添加

#selectOption {
   font-size: 12px;
   height: 20px;
   padding-top:0;
   padding-bottom:0;
}

这应该可以解决问题

关于jquery - 由于选择元素的大小,Bootstrap 选择选项被隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48687183/

相关文章:

javascript - 标题 =""中的 qtip 和 html 数据导致冲突

javascript - jQuery:检查哈希是否包含

jquery - 单击事件在元素内的斜体文本上失败

python - 使用 python Selenium 获取动态生成的内容

CSS响应式(Reactive)设计问题

javascript - 可移动的 div 但只有 div 标题才能移动所有的 div 内容

javascript - angularjs 中 $window.location.reload() 和 $route.reload() 的区别

html - 我想让 Drop left 而不是 drop down

javascript - Node.js、Ajax发送和接收Json

css - Visual Studio Code (vscode): Change command palette to look like Atom's one?