Jorge Guberte
Jorge Guberte

Reputation: 11054

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.

Upvotes: 12

Views: 32522

Answers (3)

ArtFranco
ArtFranco

Reputation: 360

In my case, I found the gradient styles were in the bootstrap.theme.css I was loading with my other styles. Once I removed this file, all went back to normal.

Upvotes: 0

Berta Nicolau
Berta Nicolau

Reputation: 128

Comment by Herr_Hansen works for me.

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

Upvotes: 4

James Donnelly
James Donnelly

Reputation: 128786

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.

Upvotes: 5

Related Questions