Twitter bootstrap html select inside pagination component is offset and not aligned

南楼画角 提交于 2020-01-05 07:48:19

问题


When I try to use an html select inside of the pagination component the html select is offset and not properly aligned. I have only included the first half of the pagination with the html select inside of it for purpose of brevity. It should illustrate the issue and you can view the JSFiddle here.

<div class="pagination pagination-large pagination-centered">
     <ul>
       <li><a class="first_record" rel="tooltip" data-original-title="First record" href="#">First</a></li>
       <li><a class="previous_record" rel="tooltip" data-original-title="Previous" href="#">Previous</a></li>
       <li><span>Display <select class="input-mini page_size">
      <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
       </li>
    </ul>
   </div>

Any help would be appreciated.


回答1:


Try the following CSS:

.pagination select {
  height: 30px;
  margin-top: -7px;
  margin-bottom: -5px;
}

Or, alternatively:

.pagination select {
  height: 2em;
  margin-top: -0.5em;
  margin-bottom: -0.4em;
}



回答2:


If your able to do it without the label, here's the CSS I ended up using.

CSS

.pagination select {
    background-color: #ffffff;
    border: 1px solid #dddddd;
    color: #337ab7;
    float: left;
    line-height: 1.42857;
    margin-left: -1px;
    padding: 6px 12px;
    position: relative;
    text-align: center;
}
.pagination > li:first-child > select {
    border-bottom-left-radius: 4px;
    border-top-left-radius: 4px;
    margin-left: 0;
}
.pagination > li:last-child > select {
    border-bottom-right-radius: 4px;
    border-top-right-radius: 4px;
}
.pagination > li > select:hover, 
.pagination > li > select:focus {
    background-color: #eeeeee;
    border-color: #dddddd;
    color: #23527c;
}

.pagination-lg > li > select {
    font-size: 18px;
    padding: 10px 16px;
}
.pagination-lg > li:first-child > select {
    border-bottom-left-radius: 6px;
    border-top-left-radius: 6px;
}
.pagination-lg > li:last-child > select {
    border-bottom-right-radius: 6px;
    border-top-right-radius: 6px;
}

.pagination-sm > li > select {
    font-size: 12px;
    padding: 5px 10px;
}
.pagination-sm > li:first-child > select {
    border-bottom-left-radius: 3px;
    border-top-left-radius: 3px;
}
.pagination-sm > li:last-child > select {
    border-bottom-right-radius: 3px;
    border-top-right-radius: 3px;
}

HTML

<div class="container"><nav>
  <ul class="pagination">
    <li>
      <a href="#" aria-label="Previous">
        <span aria-hidden="true">«</span>
      </a>
    </li>
    <li><select onchange="if (this.value) window.location.href=this.value">
      <option value="?page=1">1</option>
      <option value="?page=2">2</option>
      <option value="?page=3">3</option>
      </select></li>
    <li>
      <a href="#" aria-label="Next">
        <span aria-hidden="true">»</span>
      </a>
    </li>
  </ul>
</nav>
</div>

Example: http://www.bootply.com/KVb2hwLs57



来源:https://stackoverflow.com/questions/13617358/twitter-bootstrap-html-select-inside-pagination-component-is-offset-and-not-alig

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!