Home > Web Front-end > JS Tutorial > How to customize the small triangle style of the select box

How to customize the small triangle style of the select box

巴扎黑
Release: 2017-08-21 10:36:03
Original
1623 people have browsed it

This article mainly introduces the select custom small triangle style. It shows the operation process in detail through css HTML js code. Customizing the small triangle style can also create the effect of centering the select text. Friends who need it can refer to it

This code is the solution for most of the Internet. Here is a summary:

Make the select transparent, add a span on it to replace the select box, you can customize the small triangle style, or you can Make the select text centered.


    <p class="ui-select">
     <span>使用加息券或现金券 <i class="icon-down lMar10"></i></span>
     <select name="" id="">
      <option value="10元现金券">10元现金券</option>
      <option value="20元现金券">20元现金券</option>
      <option value="30元现金券">30元现金券</option>
      <option value="40元现金券">40元现金券</option>
     </select>
    </p>
Copy after login


.ui-select{
 width:75%;
 height:63px;
 line-height:63px;
 background-color:#ECAFB4;
 color:#fff;
 padding:0 30px;
 text-align: left;
 position: relative;
}
select{
 width:100%;
 height:63px;
 line-height:33px;
 opacity: 0;
 position: absolute;
 top:0;
 left:0;
}

/*小三角图标*/
.icon-down{
 display: inline-block;
 width:30px;
 height:16px;
 background: url("../image/newWap/wapIcons.png") -168px -96px no-repeat;
}
Copy after login


$(".ui-select select").change(function(){
  $(this).prev("span").html($(this).find("option:selected").val()+&#39;<i class="icon-down lMar10"></i>&#39;);
})
//select监测option的值的变化,添加到span中
Copy after login

The display effect is as shown in the figure:

The above is the detailed content of How to customize the small triangle style of the select box. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template