html - 如何在选择下拉菜单上设置 Font Awesome 图标?

标签 html css drop-down-menu font-awesome dropdown

我想在选择下拉菜单中设置超赞字体图标并更改背景颜色...我试过这段代码,但它不会工作..

这是我的 CSS 代码:

select {
  border-radius: 30px;
  padding: 0px 70px 1px 20px;
  margin-top: 50px;
  margin-left: 45px;
  font-size: 18px;
  border: 2px solid orange;
  box-shadow: 10px 3px 8px #888888;
  appearance: none;
  position: relative;
}
select i {
  position: absolute;
  float: right;
  background-color: orange;
  bottom: 0px;
  pointer-events: none;
}

这是我的 HTML 代码:

<div class="row">
      <p class="search">Search by Location</p>
      <select class="dropdown">
           <option>Canada</option>
      </select>
      <i class="fas fa-angle-down"></i>
</div>

enter image description here

最佳答案

编辑的答案

select.input-lg {
  -webkit-appearance: none;
  -moz-appearance: none;
  -o-appearance: none;
  /* no standardized syntax available, no ie-friendly solution available */
}

select + i.fa {
  float: right;
  margin-top: -30px;
  margin-right: 5px;
  /* this is so when you click on the chevron, your click actually goes on the dropdown menu */
  pointer-events: none;
  /* everything after this is just to cover up the original arrow */
  /* (for browsers that don't support the syntax used above) */
  background-color: #fff;
  padding-right: 5px;
}

来源:I want to change the select icon/dropdown icon to (fa-chevron-down). How can I?

您也可以关注:font awesome icon in select option

关于html - 如何在选择下拉菜单上设置 Font Awesome 图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62601634/

相关文章:

html - 如何使图像和容器具有相同的高度

html - 自定义 URL 的自定义 Pinterest 按钮(文本链接、图像或两者)

CSS 布局 - 混合绝对和 float 定位

javascript - 使用 jquery 根据选择值项更改 css

drop-down-menu - 下拉菜单在不正确的导航栏项目下方呈现

javascript - 嵌入具有自动高度的小部件

php - 为什么我的代码不能在 PHP 中处理?

html - 在下拉菜单选项中添加 CSS 矩形

javascript - 将文档末尾的元素定位在页面顶部

javascript - 为相扑下拉菜单设置选择限制