skip to Main Content

I want to increase the width of select box arrow like fa fa caret. i am not getting it how to do. I used img tag inside the each field and given position absolute and adjusted with left top properties but i think this is not proper way of doing this and even i click on the image arrow not select options are opening so i removed this. Please tell me proper solution for it.

.search-categories{
    background: #E40444 !important;
    color: #fff !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
    <style type="text/css">
    
    </style>

    <div class="col-md-12 ">
      <div class="row">
       <form action="#" method="get" id="search_mini_form">
          <div class="col-sm-offset-2 col-sm-2 catnames">
             <select name="cat" class="form-control search-categories">
                <option>Categories</option>
                <option value="3">abcd</option>
                <option value="4">abcd</option>
                <option value="5">abcd</option>
             </select>
          </div>
          <div class="col-sm-2 catnames catnames-arrow ">
             <select name="cat" class="form-control search-categories search-Hourly">
                <option>Hourly</option>
                <option value="3">abcd</option>
                <option value="4">abcd</option>
                <option value="5">abcd</option>
             </select>
          </div>
          <div class="col-sm-4 catquery ">
       <div class="input-group">
             <input type="search" class="form-control " name="q" id="location" value="" maxlength="128" placeholder="Search Place..." autocomplete="off" />
         <div class="input-group-addon catsubmit"><i class="fa fa-search"></i></div>
            </div>
          </div>
          <div id="search_autocomplete" class="search-autocomplete"></div>
       </form>
       </div>
    </div>

3

Answers


  1. better use some select element customisation plugin like select2, selectize. The appearance that these plugins create can be customised through css.

    You cannot fully control the appearance of select element in cross browser manner with css alone.

    Login or Signup to reply.
  2. It’s very complicated to style form elements cross-browser because very browser has different look for form elements (especially checkbox, radio, select, progress).

    I suggest using some plugin like select2 so you can easily style very element browser-independent.

    $(document).ready(function() {
      $('select').select2({
        width: '200px'
      });
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <link href="http://select2.github.io/select2/select2-3.5.3/select2.css" rel="stylesheet" />
    <script src="http://select2.github.io/select2/select2-3.5.3/select2.js"></script>
    
    
    <select>
      <option>Op 1</option>
      <option>Op 2</option>
      <option>Op 3</option>
      <option>Op 4</option>
    </select>
    Login or Signup to reply.
  3. You can use the css triangle to make the arrow.

    HTML

    <div class="selectwrap">
          <select>
            <option>Option 1</option>
            <option>Option 3</option>
            <option>Option 4</option>
          </select>
    </div>
    

    CSS

    select {
      border: 1px solid #ccc;
      height: 34px;
      width: 250px;
      padding: 6px 12px;
      line-height: 1.42857143;
    }
    
    .selectwrap {
      position: relative;
      float: left;
    }
    
    .selectwrap:after {
      content: "";
      position: absolute;
      width: 0; 
      height: 0; 
      border-left: 8px solid transparent;
      border-right: 8px solid transparent;  
      border-top: 8px solid #000;
      right: 4px;
      top: 14px;
      pointer-events: none;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search