Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do not change CSS when hover over bootstrap button

I am using a btn-group like this: http://jsfiddle.net/dy9uH/34/

I don't want my users to think the button to the left is click-able but don't like how the button looks when I add the disabled class. How can I make sure nothing happens when a user hovers over the left button? I'd prefer not to edit bootstrap.css because I have other buttons that utilize the .btn-group class that I need functioning as usual.

like image 898
Zaki Aziz Avatar asked Feb 19 '13 02:02

Zaki Aziz


2 Answers

I think the only solution is to over ride the bootstrap styles with your custom changes.

  1. Add a custom class to the btn ex: special
  2. Define the override style as follows in a custom css file
  3. Include the custom file in your page

Css:

.btn.special {
    background-color: #F5F5F5;
    color: #333333;
    background-image: linear-gradient(to bottom, #FFFFFF, #E6E6E6);
    text-decoration: none;
    background-position: 0;
    transition: none;
}

Demo: Fiddle

like image 78
Arun P Johny Avatar answered Oct 17 '22 04:10

Arun P Johny


I'm going to assume you want to use disabled as well so the button is actually disabled. You will need to override some bootstrap

I would do the following

HTML

<div class="btn-group">
  <button class="btn special" disabled>I'm Special</button>
  <button class="btn dropdown-toggle" data-toggle="dropdown">
    <span class="caret"></span>
  </button>
  <ul class="dropdown-menu">
    <!-- dropdown menu links -->
  </ul>
</div>

CSS

.special,
.special.disabled,
.special[disabled] 
.special.disabled:hover,
.special[disabled]:hover,
.special.disabled:focus,
.special[disabled]:focus {
  display: inline-block;
  *display: inline;
  padding: 4px 12px;
  margin-bottom: 0;
  *margin-left: .3em;
  font-size: 14px;
  line-height: 20px;
  color: #333333;
  text-align: center;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
  vertical-align: middle;
  cursor: pointer;
  background-color: #f5f5f5;
  *background-color: #e6e6e6;
  background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6) !important;
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6)) !important;
  background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6) !important;
  background-image: -o-linear-gradient(top, #ffffff, #e6e6e6) !important;
  background-image: linear-gradient(to bottom, #ffffff, #e6e6e6) !important;
  background-repeat: repeat-x !important;
  opacity: 1 !important;
  filter: alpha(opacity=100) !important;
     background-position: 0 0;
  -webkit-transition:none;
     -moz-transition:none;
       -o-transition: none;
          transition: none;
  border: 1px solid #cccccc;
  *border: 0;
  border-color: #e6e6e6 #e6e6e6 #bfbfbf;
  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
  border-bottom-color: #b3b3b3;
  -webkit-border-radius: 4px;
     -moz-border-radius: 4px;
          border-radius: 4px;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
  filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
  *zoom: 1;
  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
     -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
          box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}

Note the disabled selectors.

HOWEVER it should come as a surprise to no one that this is only partially supported in IE!

Fiddle

like image 29
Jon P Avatar answered Oct 17 '22 04:10

Jon P