html - 如何更改选择框箭头

标签 html css select

<分区>

我需要你的帮助。

我似乎无法全神贯注地解决这个问题。如何更改选择框中默认的 Windows 7、IE 10 默认箭头:enter image description here使用下面的自定义箭头使其看起来像这样:enter image description here .

这是我想要使用的箭头:enter image description here

这是我的 HTML 标记:

<!DOCTYPE html>
<html>
<head>
   <style type="text/css">
   select { font: normal 13px Arial; color: #000;}
   .container {
         border: 1px solid red;
         position: relative; width: 124px; height: 18px; overflow: hidden;
    }
   .inpSelect {
        color: black; background: #ffa;
        position: absolute; width: 128px; top: -2px; left: -2px;
    }
   </style>

<script type="text/javascript">
</script>

</head>

<body>

<div class="container">
    <select class="inpSelect" name="xxx">
        <option value="0" selected="selected">actual browser</option>
        <option value="1">IE</option>
        <option value="2">Firefox</option>
        <option value="3">Opera</option>
        <option value="4">Safari</option>
    </select>
</div>
</body>

</html>

最佳答案

可以用纯css箭头跳过容器或背景图片:

select {

  /* make arrow and background */

  background:
    linear-gradient(45deg, transparent 50%, blue 50%),
    linear-gradient(135deg, blue 50%, transparent 50%),
    linear-gradient(to right, skyblue, skyblue);
  background-position:
    calc(100% - 21px) calc(1em + 2px),
    calc(100% - 16px) calc(1em + 2px),
    100% 0;
  background-size:
    5px 5px,
    5px 5px,
    2.5em 2.5em;
  background-repeat: no-repeat;

  /* styling and reset */

  border: thin solid blue;
  font: 300 1em/100% "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5em;
  padding: 0.5em 3.5em 0.5em 1em;

  /* reset */

  border-radius: 0;
  margin: 0;      
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  -webkit-appearance:none;
  -moz-appearance:none;
}

样本 here

关于html - 如何更改选择框箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22153080/

相关文章:

html - 使用嵌入式 CSS 将图像添加到背景中

javascript - 函数参数...函数检查(对象){}

html - 在 HTML 上相对居中一个 div

html - 封闭的 div 高于包含按钮

python - 如何在 CSS 选择器 scrapy 中使用正则表达式

html - 下拉列表中的最后一个选项在 Google Chrome 中没有获得悬停效果 32.0.1700.76 m

MySQL:根据特定字段中的数据选择所有字段

javascript - HTML:如何创建搜索栏?

javascript - Bootstrap 形式的光谱颜色选择器插件

PHP 和 MySQL - Select 语句未返回正确的顺序