CSS Custom Dropdown Select that works across all browsers IE7+ FF Webkit

后端 未结 6 510
闹比i
闹比i 2020-12-30 19:37

I would like to make a custom dropdown that works across all the browsers. I created one here but the arrow is not clickable. If I set it as the background for the select, t

6条回答
  •  心在旅途
    2020-12-30 20:01

    I was also having a similar problem. Finally found one solution at https://techmeals.com/fe/questions/htmlcss/4/How-to-customize-the-select-drop-down-in-css-which-works-for-all-the-browsers

    Note:

    1) For Firefox support there is special CSS handling for SELECT element's parent, please take a closer look.

    2) Download the down.png from Down.png

    CSS code

            /* For Firefox browser we need to style for SELECT element parent. */
    
            @-moz-document url-prefix() {
    
                /* Please note this is the parent of "SELECT" element */
    
                .select-example {   
                    background: url('https://techmeals.com/external/images/down.png');
                    background-color: #FFFFFF;
                    border: 1px solid #9e9e9e;
                    background-size: auto 6px;
                    background-repeat: no-repeat;
                    background-position: 96% 13px;
                }
            }
    
            /* IE specific styles */
            @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) 
            {
                    select.my-select-box {
                    padding: 0 0 0 5px;
                }
            }
    
            /* IE specific styles */
            @supports (-ms-accelerator:true) {
                    select.my-select-box {
                    padding: 0 0 0 5px;
                }
            }
    
            select.my-select-box  {
                outline: none;
                background: #fff;
                -moz-appearance: window;
                -webkit-appearance: none;
                border-radius: 0px;
                text-overflow: "";
                background-image: url('https://techmeals.com/external/images/down.png');
                background-size: auto 6px;
                background-repeat: no-repeat;
                background-position: 96% 13px;
                cursor: pointer;
                height: 30px;
                width: 100%;
                border: 1px solid #9e9e9e;
                padding: 0 15px 0 5px;
                padding-right: 15px\9;      /* This will be apllied only to IE 7, IE 8 and IE 9 as */
                *padding-right: 15px;        /* This will be apllied only to IE 7 and below. */
                _padding-right: 15px;       /* This will be apllied only to IE 6 and below. */
            }
    

    HTML code

        

提交回复
热议问题