Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset or remove the gradient on the select element in Twitter Bootstrap?

I need to completely remove or override specifically the gradient on the select element. I've downloaded a custom copy of Bootstrap, without the form components, and the select element appears the way i need, but everything else is obviously gone, and i only need to remove the select gradient. Thanks.

like image 431
Jorge Guberte Avatar asked Feb 14 '13 15:02

Jorge Guberte


2 Answers

The gradients will be on the .btn-* class (assuming you're using button dropdowns).

For example (with btn-primary):

.btn-primary {
  color: #ffffff;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  background-color: #006dcc;
  *background-color: #0044cc;
  background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
  background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
  background-image: -o-linear-gradient(top, #0088cc, #0044cc);
  background-image: linear-gradient(to bottom, #0088cc, #0044cc);
  background-repeat: repeat-x;
  border-color: #0044cc #0044cc #002a80;
  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);
  filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
}

To remove the gradient, you'd simply remove all the background properties (including the filters at the bottom) apart from background-color;:

.btn-primary {
  color: #ffffff;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  background-color: #006dcc;
  border-color: #0044cc #0044cc #002a80;
  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
}

You'd also want to finish up by using a single-color border:

.btn-primary {
  color: #ffffff;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  background-color: #006dcc;
  border-color: #0044cc;
}

You'd also need to do the same for the .btn-*:hover, :focus and :active styles.

like image 148
James Donnelly Avatar answered Nov 07 '22 08:11

James Donnelly


Comment by Herr_Hansen works for me.

For Safari, try adding -webkit-appearance:none; to <select> with CSS

like image 39
Berta Nicolau Avatar answered Nov 07 '22 08:11

Berta Nicolau