How to remove the arrow from a select element in Firefox

后端 未结 30 1232
北恋
北恋 2020-11-22 15:58

I\'m trying to style a select element using CSS3. I\'m getting the results I desire in WebKit (Chrome / Safari), but Firefox isn\'t playing nicely (I\'m not ev

相关标签:
30条回答
  • 2020-11-22 16:40
    /* Try this in FF30+ Covers up the arrow, turns off the background */ 
    /* still lets you style the border around the image and allows selection on the arrow */
    
    
    @-moz-document url-prefix() {
    
        .yourClass select {
            text-overflow: '';
            text-indent: -1px;
            -moz-appearance: none;
            background: none;
    
        }
    
        /*fix for popup in FF30 */
        .yourClass:after {
            position: absolute;
            margin-left: -27px;
            height: 22px;
            border-top-right-radius: 6px;
            border-bottom-right-radius: 6px;
            content: url('../images/yourArrow.svg');
            pointer-events: none;
            overflow: hidden;
            border-right: 1px solid #yourBorderColour;
            border-top: 1px solid #yourBorderColour;
            border-bottom: 1px solid #yourBorderColour; 
        }
    }
    
    0 讨论(0)
  • 2020-11-22 16:42

    Jordan Young's answer is the best. But if you can't or don't want to change your HTML, you might consider just removing the custom down arrow served to Chrome, Safari, etc and leaving firefox's default arrow - but without double arrows resulting. Not ideal, but a good quick fix that doesn't add any HTML and doesn't compromise your custom look in other browsers.

    <select>
      <option value='1'> First option </option>
      <option value='2'> Second option </option>
    </select>
    

    CSS:

    select {
       background-image: url('images/select_arrow.gif');
       background-repeat: no-repeat;
       background-position: right center;
       padding-right: 20px;
    }
    
    @-moz-document url-prefix() {
      select {
        background-image: none;
      }
    }
    
    0 讨论(0)
  • 2020-11-22 16:43

    I am styling the select just likes this

    <select style="     -moz-appearance: radio-container;
                    -webkit-appearance: none;
                     appearance: none;
    ">
    

    It works for me in FF, Safari and Chrome in all versions I've tested.

    In IE I put:

     select::-ms-expand {
     display: none;
    }
    /*to remove in all selects*/
    

    Also you can: .yourclass::-ms-expand {display: none; } .yourid::-ms-exapan {display: none; }

    0 讨论(0)
  • 2020-11-22 16:43

    This works (tested on Firefox 23.0.1):

    select {
        -moz-appearance: radio-container;
    }
    
    0 讨论(0)
  • 2020-11-22 16:45

    It's a huge hack, but -moz-appearance: menulist-text might do the trick.

    0 讨论(0)
  • 2020-11-22 16:46

    The trick that works for me is to make select width more than 100% and apply overflow:hidden

    select {
        overflow:hidden;
        width: 120%;
    }
    

    This is the only way right now to hide dropdown arrow in FF.

    BTW. if you want beautiful dropdowns use http://harvesthq.github.com/chosen/

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