【问题标题】:The glyphicons height not matching with select2 dropdown字形高度与 select2 下拉列表不匹配
【发布时间】:2017-07-04 03:17:50
【问题描述】:

当我添加 select2 下拉菜单时,字形图标高度不同

这是html代码

 <form class="well form-horizontal" action=" " method="post" id="user_edit">

  <div class="form-group">
        <label class="col-md-1 nopadding control-label"></label>
        <div class="col-md-8 nopadding inputGroupContainer">
            <div class="input-group field-width">

             <span class="input-group-addon" >
              <i class="fa fa-venus-mars" ></i></span>
               <select name="gender" id="gender" class="gender form-control 
     js-example-basic-single">
                    <option value="">Not Telling</option>
                    <option value="m">Male</option>
                    <option value="f">Female</option>
                </select>

            </div>
        </div>
    </div>
    </form>

js文件

$(document).ready(function() {
    $(".js-example-basic-single").select2();
});

我为 select2 添加的 css 文件

.glyphicon{
color:#007bcc;
 }
 .select2-selection__rendered{
 line-height: 32px!important;
 }
 [class^='select2'] {
 border-radius: 0px !important;
 }

 .select2-selection__arrow{
  height: 34px;!important;
  }
 .select2-container--default .select2-selection--single{
 background-color: #eeeeee !important;
 height: 34px!important;
 font-size: 15px;!important;
  margin-top: 0.5px!important;
 margin-left: -1px!important;

 }

当我将页面缩放到相同高度的 100% 以上时。

【问题讨论】:

  • 你能在这里摆弄一下吗..

标签: html css jquery-select2 glyphicons


【解决方案1】:

.select2-container--default .select2-selection--single 中删除margin-top: 0.5px!important;

$(document).ready(function() {
    $(".js-example-basic-single").select2();
});
.glyphicon{
color:#007bcc;
 }
 .select2-selection__rendered{
 line-height: 32px!important;
 }
 [class^='select2'] {
 border-radius: 0px !important;
 }

 .select2-selection__arrow{
  height: 34px;!important;
  }
 .select2-container--default .select2-selection--single{
 background-color: #eeeeee !important;
 height: 34px!important;
 font-size: 15px;!important;

 margin-left: -1px!important;

 }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css">
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
     <form class="well form-horizontal" action=" " method="post" id="user_edit">
  <div class="form-group">
        <label class="col-md-1 nopadding control-label"></label>
        <div class="col-md-8 nopadding inputGroupContainer">
            <div class="input-group field-width">
             <span class="input-group-addon" >
              <i class="fa fa-venus-mars" ></i></span>
               <select name="gender" id="gender" class="gender form-control 
     js-example-basic-single">
                    <option value="">Not Telling</option>
                    <option value="m">Male</option>
                    <option value="f">Female</option>
                </select>
            </div>
        </div>
    </div>
    </form>

【讨论】:

  • 为什么我放大150%后行的位置不一样
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-25
  • 1970-01-01
  • 1970-01-01
  • 2016-12-08
  • 2020-02-17
相关资源
最近更新 更多