133

This seems like a trivial problem, but I can't figure it out.

On Bootstraps own website they have the Select example.

bootstrap select



Looking at the code it looks like there's a border-radius of 4 on that select element. enter image description here



My hope would be that changing that border-radius to 0 would then remove the border-radius from the select element, however, that's not the case - as seen in the picture below.

enter image description here



I've explored all the CSS that is changing that select element but none of it seems to remove the border radius.

Tyler McGinnis
  • 34,836
  • 16
  • 72
  • 77

6 Answers6

257

Here is a version that works in all modern browsers. The key is using appearance:none which removes the default formatting. Since all of the formatting is gone, you have to add back in the arrow that visually differentiates the select from the input. Note: appearance is not supported in IE.

Working example: https://jsfiddle.net/gs2q1c7p/

select:not([multiple]) {
    -webkit-appearance: none;
    -moz-appearance: none;
    background-position: right 50%;
    background-repeat: no-repeat;
    background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NDZFNDEwNjlGNzFEMTFFMkJEQ0VDRTM1N0RCMzMyMkIiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NDZFNDEwNkFGNzFEMTFFMkJEQ0VDRTM1N0RCMzMyMkIiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo0NkU0MTA2N0Y3MUQxMUUyQkRDRUNFMzU3REIzMzIyQiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo0NkU0MTA2OEY3MUQxMUUyQkRDRUNFMzU3REIzMzIyQiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PuGsgwQAAAA5SURBVHjaYvz//z8DOYCJgUxAf42MQIzTk0D/M+KzkRGPoQSdykiKJrBGpOhgJFYTWNEIiEeAAAMAzNENEOH+do8AAAAASUVORK5CYII=);
    padding: .5em;
    padding-right: 1.5em
}

#mySelect {
    border-radius: 0
}
<select id="mySelect">
    <option>Option 1</option>
    <option>Option 2</option>
</select>

Based on Arno Tenkink's suggestion in the comments, here is an example using a instead of a for the arrow icon.

select:not([multiple]) {
    -webkit-appearance: none;
    -moz-appearance: none;
    background-position: right 50%;
    background-repeat: no-repeat;
    background-image: url('data:image/svg+xml;utf8,<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="12" version="1"><path d="M4 8L0 4h8z"/></svg>');
    padding: .5em;
    padding-right: 1.5em
}

#mySelect {
    border-radius: 0
}
<select id="mySelect">
    <option>Option 1</option>
    <option>Option 2</option>
</select>
Eric
  • 6,563
  • 5
  • 42
  • 66
  • 7
    You can also use a SVG for this. ` ` it saves same file space. It's also cacheable and easier to maintain. Copy this into a file and save as .svg and use it as a background. – Arno Tenkink Mar 11 '16 at 10:09
215

In addition to border-radius: 0, add -webkit-appearance: none;.

alex
  • 479,566
  • 201
  • 878
  • 984
user1732055
  • 2,517
  • 1
  • 13
  • 22
  • 2
    solution is right - but not being able to see why is this happening in dev tools is just straight wrong. thanks for solving the riddle man! – mmln Aug 06 '14 at 22:33
  • 101
    It works but not perfect, `-webkit-appearance: none;` will cause the select lack of arrow indicator on the right side. – nightire Aug 15 '14 at 07:12
  • 41
    @nightire It worked for me if you use `border: 0` and add an outline like: `outline: 1px inset black; outline-offset:-1px`. Will keep the arrows and you can fake the border with the outline. – Filipe Pereira Nov 05 '14 at 09:53
  • @FilipePereira That not solved the problem in my case, but it added border outline with black color. it coming in mozilla not in chrome. – Akilsree1 Mar 16 '15 at 05:57
  • remove the line `-webkit-appearance:none;` from css. or else expected output not come in Chrome Browser. – Akilsree1 Mar 16 '15 at 06:00
  • Not an ideal solution because this removes the select indicator arrows as well. – Joshua Apr 30 '15 at 19:12
  • 2
    Yeah this is not really a solution because, like everyone has said, the selector arrow disappears. – Chad Johnson May 14 '15 at 00:20
  • 1
    @FilipePereira this works but outline-offset is not supported for IE – avoliva Aug 14 '15 at 23:04
  • 2
    Don't forget IE! :) select::-ms-expand { display: none; } – Kyle Hawk Mar 30 '16 at 15:19
  • 1
    For bootstrap@4 users, adding `custom-select` class will bring the arrows back. – elquimista Oct 17 '18 at 09:46
13

I had the same issue and while user1732055's answer fixes the border, it removes the dropdown arrows. I solved this by removing the border from the select element and creating a wrapper span which has a border.

html:

<span class="select-wrapper">
    <select class="form-control no-radius">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
    </select>
</span>

css:

select.no-radius{
    border:none;
}    
.select-wrapper{
    border: 1px solid black;
    border-radius: 0px;
}

https://jsfiddle.net/Lrqh0drd/6/

Logan Besecker
  • 2,733
  • 4
  • 23
  • 21
  • This works only if the select has white background. Otherwise there will be a radius if another color is used. – MichalCh Feb 22 '17 at 18:00
  • Hi @MichalCh, good catch! One way to get around this would be to set the background-color of the wrapper to the same value as the select element. Here's a modified version on jsfiddle to demonstrate: [https://jsfiddle.net/Lrqh0drd/75/](https://jsfiddle.net/Lrqh0drd/75/) – Logan Besecker Feb 24 '17 at 18:20
  • This is the cleanest solution. – Nikolay Tsenkov Dec 11 '18 at 06:59
2

You can use -webkit-border-radius: 0;. Like this:-

-webkit-border-radius: 0;
border: 0;
outline: 1px solid grey;
outline-offset: -1px;

This will give square corners as well as dropdown arrows. Using -webkit-appearance: none; is not recommended as it will turn off all the styling done by Chrome.

gns
  • 81
  • 8
0

Using the SVG from @ArnoTenkink as an data url combined with the accepted answer, this gives us the perfect solution for retina displays.

select.form-control:not([multiple]) {
    border-radius: 0;
    appearance: none;
    background-position: right 50%;
    background-repeat: no-repeat;
    background-image: url(data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%20%3C%21DOCTYPE%20svg%20PUBLIC%20%22-//W3C//DTD%20SVG%201.1//EN%22%20%22http%3A//www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd%22%3E%20%3Csvg%20version%3D%221.1%22%20id%3D%22Layer_1%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20xmlns%3Axlink%3D%22http%3A//www.w3.org/1999/xlink%22%20x%3D%220px%22%20y%3D%220px%22%20width%3D%2214px%22%20height%3D%2212px%22%20viewBox%3D%220%200%2014%2012%22%20enable-background%3D%22new%200%200%2014%2012%22%20xml%3Aspace%3D%22preserve%22%3E%20%3Cpolygon%20points%3D%223.862%2C7.931%200%2C4.069%207.725%2C4.069%20%22/%3E%3C/svg%3E);
    padding: .5em;
    padding-right: 1.5em
}
Marius
  • 309
  • 1
  • 5
  • 16
-5

the class is called:

.form-control { border-radius: 0; }

be sure to insert the override after including bootstraps css.

If you ONLY want to remove the radius on select form-controls use

select.form-control { ... }

instead

EDIT: works for me on chrome, firefox, opera, and safari, IE9+ (all running on linux/safari & IE on playonlinux)

jBear Graphics
  • 153
  • 1
  • 7
  • I specifically showed in the question how I changed the border-radius on form control and it didn't work..., which is what prompted me to ask the question. – Tyler McGinnis Jun 13 '14 at 16:47
  • 1
    http://jsfiddle.net/Ut4y9/3/ here is a working fiddle. if it's still not working on your machine, could you please specify the browser you are using? I cannot reproduce your problem. sorry – jBear Graphics Jun 13 '14 at 16:55
  • Weird. I'm using the latest version of Chrome. Obviously it's something machine specific since you're both seeing it changed. Edit your answer so I can change my downvote :) – Tyler McGinnis Jun 13 '14 at 17:12
  • I've got the same issue. Despite my overriding the border-radius it still shows. Driving me nuts. – user1732055 Jul 15 '14 at 18:54
  • This is still the case with the most recent Bootstrap 3 – genkilabs May 13 '15 at 19:13