自定义 HTML Select 箭头图像

Custom HTML Select Arrow Image

我想隐藏 html select 列表的默认箭头并向列表添加自定义图像(箭头)。

.form-inline select {
            margin: 10px 35px 15px 0px;
            background-color: #fff;
            font-size: 30px;
            width: 80px;
            color: #000;
            background-image: url("https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/down4-512.png") center bottom no-repeat;
            cursor: pointer;
            display: block;
            outline: none;
            -webkit-appearance: none;
            appearance: none;
            border: none !important;
            justify-content:center;
            align-items:center;
            text-align:center;
        } 

这是我目前的风格。它没有按我的意愿显示箭头。请帮帮我。

您将 backgroundbackground-image CSS 样式混合在一起,难怪您的样式不起作用:

简短版本:(我使用 background 而不是 background-image

background: salmon url("https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/down4-512.png") no-repeat center calc(100% - 2px);
background-size: 24px 24px;

但是为了方便修改,我推荐这种方式:

background-color: #fff;
background-image: url("https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/down4-512.png");
background-size: 24px 24px;
background-repeat: no-repeat;
background-position: center calc(100% - 2px);

仅供参考,此 CSS 部分将隐藏浏览器的默认箭头:

-webkit-appearance: none;
appearance: none;