更改下拉箭头的颜色和外观 [英] Change color and appearance of drop down arrow

查看:25
本文介绍了更改下拉箭头的颜色和外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改下拉列表箭头的默认外观,以便在不同浏览器中看起来相同.有没有办法使用 CSS 或其他方式覆盖下拉箭头的默认外观?

解决方案

您可以使用 CSS 实现这一点,但您并没有在技术上改变箭头本身.

在这个例子中,我实际上隐藏了默认箭头,而是显示了我自己的箭头.

.styleSelect select {背景:透明;宽度:168px;填充:5px;字体大小:16px;行高:1;边框:0;边界半径:0;高度:34px;-webkit 外观:无;-moz-外观:无;外观:无;颜色:#000;}.styleSelect {宽度:140px;高度:34px;溢出:隐藏;背景: url("images/downArrow.png") 无重复权利 #fff;边框:2px 实心 #000;}

<选择类=单位"><option value="Metres">Metres</option><option value="Feet">Feet</option><option value="Fathoms">Fathoms</option></选择>

I want to change the default appearance of the arrow of a dropdown list so that looks the same across browsers. Is there a way to override the default look and feel of the drop down arrow using CSS or otherwise ?

解决方案

You can acheive this with CSS but you are not techinically changing the arrow itself.

In this example I am actually hiding the default arrow and displaying my own arrow instead.

.styleSelect select {
  background: transparent;
  width: 168px;
  padding: 5px;
  font-size: 16px;
  line-height: 1;
  border: 0;
  border-radius: 0;
  height: 34px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  color: #000;
}

.styleSelect {
  width: 140px;
  height: 34px;
  overflow: hidden;
  background: url("images/downArrow.png") no-repeat right #fff;
  border: 2px solid #000;
}

<div class="styleSelect">
  <select class="units">
    <option value="Metres">Metres</option>
    <option value="Feet">Feet</option>
    <option value="Fathoms">Fathoms</option>
  </select>
</div>

这篇关于更改下拉箭头的颜色和外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆