How to style the

后端 未结 3 1873
臣服心动
臣服心动 2020-11-22 11:31

Note: This question is not about making a custom dropdown. It\'s only about possibilities of styling elements within the select element in CSS

3条回答
  •  一向
    一向 (楼主)
    2020-11-22 11:49

    EDIT 2015 May

    Disclaimer: I've taken the snippet from the answer linked below:

    Important Update!

    In addition to WebKit, as of Firefox 35 we'll be able to use the appearance property:

    Using -moz-appearance with the none value on a combobox now remove the dropdown button

    So now in order to hide the default styling, it's as easy as adding the following rules on our select element:

    select {
       -webkit-appearance: none;
       -moz-appearance: none;
       appearance: none;
    }
    

    For IE 11 support, you can use [::-ms-expand][15].

    select::-ms-expand { /* for IE 11 */
        display: none;
    }
    

    Old Answer

    Unfortunately what you ask is not possible by using pure CSS. However, here is something similar that you can choose as a work around. Check the live code below.

    div { 
      margin: 10px;
      padding: 10px; 
      border: 2px solid purple; 
      width: 200px;
      -webkit-border-radius: 5px;
      -moz-border-radius: 5px;
      border-radius: 5px;
    }
    div > ul { display: none; }
    div:hover > ul {display: block; background: #f9f9f9; border-top: 1px solid purple;}
    div:hover > ul > li { padding: 5px; border-bottom: 1px solid #4f4f4f;}
    div:hover > ul > li:hover { background: white;}
    div:hover > ul > li:hover > a { color: red; }

    EDIT

    Here is the question that you asked some time ago. How to style a

    提交评论

提交回复
热议问题