Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
624 views
in Technique[技术] by (71.8m points)

html - How to change bootstrap select arrows to glyphicon?

I want to achieve something like this, except arrow should be bootstrap glyphicon icon:

desired select menu

I really don't know how to make this using bootstrap. I was trying to do this like this:

<div class="my-select">
  <div class="select-side">
    <i class="glyphicon glyphicon-menu-down"></i>
  </div>
  <select class="form-control" id="sel1">
    <option>1</option>
    <option>2</option>
    <option>3</option>
  </select>
</div>

by setting up select-side as absolute on my-select and manipulate it, but no matter how hard i try, i can't fit this blue div with border under whole select. AND when you click on that arrow- it doesn't work.

Only problem I have right now is that clicking on select-side div won't open panel.

EDIT2: Problem Solved, WORKING DEMO:

http://codepen.io/Deathgazeroo/pen/wWWMqJ

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can achieve it by using .input-group and .input-group-addon classes of bootstrap. You can hide down arrow by using below css code in your stylesheet. Below is the code snippet :

select {
  -webkit-appearance: none;
  -moz-appearance: none;
  text-indent: 1px;
  text-overflow: '';
}
<div class="input-group">

  <select class="form-control">
    <option>1</option>
    <option>2</option>
    <option>3</option>
  </select>
  <span class="input-group-btn"><i class="glyphicon glyphicon-menu-down"></i></span>
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...