CSS Select box arrow style

前端 未结 2 1479
广开言路
广开言路 2020-11-28 16:33

I want to remove the default arrow from the select box and want to use custom icon. From the previous answers on SO, I have found out that it is not possible (to make it wor

相关标签:
2条回答
  • 2020-11-28 16:49

    Try to replace the

    padding: 2px 30px 2px 2px;
    

    with

    padding: 2px 2px 2px 2px;
    

    It should work.

    0 讨论(0)
  • 2020-11-28 17:00

    Please follow the way like below:

    .selectParent {
    	width:120px;
    	overflow:hidden;   
    }
    .selectParent select { 
    	display: block;
    	width: 100%;
    	padding: 2px 25px 2px 2px; 
    	border: none; 
    	background: url("http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/br_down.png") right center no-repeat; 
    	appearance: none; 
    	-webkit-appearance: none;
    	-moz-appearance: none; 
    }
    .selectParent.left select {
    	direction: rtl;
    	padding: 2px 2px 2px 25px;
    	background-position: left center;
    }
    /* for IE and Edge */ 
    select::-ms-expand { 
    	display: none; 
    }
    <div class="selectParent">
      <select>
        <option value="1">Option 1</option>
        <option value="2">Option 2</option>           
       </select>
    </div>
    <br />
    <div class="selectParent left">
      <select>
        <option value="1">Option 1</option>
        <option value="2">Option 2</option>           
       </select>
    </div>

    0 讨论(0)
提交回复
热议问题