如何通过css自定义选择元素?

Roh*_*zad 10 html css

嘿我多次搜索如何创建一个像下图一样的选择元素

在此输入图像描述

我的代码是

<select>
    <option>-- Select City --</optoin>
    <option>Delhi</option>
    <option>Gurgaon</option>
</select>
Run Code Online (Sandbox Code Playgroud)

这在jquery中可用,但我想使用纯css.

提前致谢 ....

Sha*_*ora 21

看看它的基于CSS的选择菜单,你可以自定义它: - http://jsfiddle.net/XxkSC/553/

HTML

label.custom-select {
    position: relative;
    display: inline-block;

}

.custom-select select {
    display: inline-block;
    padding: 4px 3px 3px 5px;
    margin: 0;
    font: inherit;
    outline:none; /* remove focus ring from Webkit */
    line-height: 1.2;
    background: #000;
    color:white;
    border:0;
}

/* Select arrow styling */
.custom-select:after {
    content: "?";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    font-size: 60%;
    line-height: 30px;
    padding: 0 7px;
    background: #000;
    color: white;
    pointer-events: none;
}

.no-pointer-events .custom-select:after {
    content: none;
}
Run Code Online (Sandbox Code Playgroud)

CSS

<label class="custom-select">
    <select>
        <option>Sushi</option>
        <option>Blue cheese with crackers</option>
        <option>Steak</option>
        <option>Other</option>
    </select>
</label>
Run Code Online (Sandbox Code Playgroud)