Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何更改选择框箭头_Html_Css_Select - Fatal编程技术网

Html 如何更改选择框箭头

Html 如何更改选择框箭头,html,css,select,Html,Css,Select,我需要你的帮助 我似乎不能把我的头绕在这一个上面去想它。如何更改选择框中的默认Windows 7,IE 10默认箭头:使用下面的自定义箭头使其看起来像这样: 这是我想要使用的箭头: 以下是我的HTML标记: <!DOCTYPE html> <html> <head> <style type="text/css"> select { font: normal 13px Arial; color: #000;} .container

我需要你的帮助

我似乎不能把我的头绕在这一个上面去想它。如何更改选择框中的默认Windows 7,IE 10默认箭头:使用下面的自定义箭头使其看起来像这样:

这是我想要使用的箭头:

以下是我的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 {
    width: 268px;
    padding: 5px;
    font-size: 16px;
    line-height: 1;
    border: 0;
    border-radius: 5px;
    height: 34px;
    background: url(http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/br_down.png) no-repeat right #ddd;
    -webkit-appearance: none;
    background-position-x: 244px;
}

您可以使用纯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;
}

示例

固定宽度包装器元素内的固定宽度选项标记,包装器元素上有背景图像,选择标记上使用背景透明,还使用溢出:隐藏;在父元素上,就这样,完成了…为什么需要这样做?只是为了在所有浏览器中实现像素完美??这似乎只适用于Chrome。在Firefox中它根本不起作用,而在IE中它给出了一个混合的结果class@Taylor只需在IETaylor中添加select::-ms expand{display:none;},您应该使用:-moz外观:none;为了在firefox下工作。。。实际上,上面的解决方案远没有那么复杂,也更容易维护!对代码更改的一个小改进`background-position-x:244px;`至`背景位置:右侧;`使其响应在IE中不起作用,因为它依赖于-webkit外观和-mox外观。虽然听起来Edge确实支持它,但出于互操作的原因,Microsoft Edge和IE Mobile支持带有-webkit-前缀的属性,而不是-ms-的属性尽管可以通过使用select::-ms expand{display:none;}来解决这个问题,但这太棒了!我还发现给选择框一个与2.5em背景大小相同的填充权是很有用的;对于包含大量文本的小框或选项,文本将位于按钮后面而不是顶部。感谢@MarkBoltuc的提示。选择::-ms expand{display:none;}对Edge有帮助。谢谢。。!!因此,如何在mozilla中删除箭头的白色背景,而不是整个箭头
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;
}