3

I can make an input element respond to :hover and :hover:disable

But looks like a div doesn't respond the same.

.btn {
  width: 99px;
  border-color: 2px #787878;
  background-color: #CACACA;
  margin-left: 76px;
  margin-top: 21px;
  position: relative;
  border-radius: 26px;
  -moz-border-radius: 26px;
  -webkit-border-radius: 26px;
  cursor: pointer;
}
.btn:hover:disabled {
  background: red;
  cursor: no-drop;
}
<div class="btn" id="divDisable" style=" height: 30px;line-height: 30px; text-align: center;" disabled>Disabled
</div>

<input class="btn" id="iDisabled" type="submit" value="Disabled" disabled>

Full Sample with everything i tried

Bonus Info

Question was answer div doesn't have Disable

Make div content Disable

http://jsfiddle.net/WS47f/

Community
  • 1
  • 1
Juan Carlos Oropeza
  • 47,252
  • 12
  • 78
  • 118

3 Answers3

2

A div element doesn't have a disable attribute. You could add a class in this case for your CSS.

div.divDisable:hover {}
Cjmarkham
  • 9,484
  • 5
  • 48
  • 81
  • I will try that, make sense if there isn't disable attribute. I rechange the Title again. The issue isnt disable the DIV. The issue was style a disable DIV. – Juan Carlos Oropeza Mar 20 '15 at 22:17
1

Maybe late for the party, but solution is to use .btn[disabled]:hover instead of .btn:disabled:hover. First one does not detect disabled state (which doesn't exist on div) but rather targets existence of disabled attribute.

.btn {
  width: 99px;
  border-color: 2px #787878;
  background-color: #CACACA;
  margin-left: 76px;
  margin-top: 21px;
  position: relative;
  border-radius: 26px;
  -moz-border-radius: 26px;
  -webkit-border-radius: 26px;
  cursor: pointer;
}
.btn[disabled]:hover {
  background: red;
  cursor: no-drop;
}
<div class="btn" id="divDisable" style=" height: 30px;line-height: 30px; text-align: center;" disabled>Disabled
</div>

<input class="btn" id="iDisabled" type="submit" value="Disabled" disabled>
Miroslav Jonas
  • 5,407
  • 1
  • 27
  • 41
-1

To get both to do the same thing do:

    .btn:hover {
  background: red;
  cursor: no-drop;
}

Here is a Fiddle that demonstrates: https://jsfiddle.net/cs8rbjkh/

BlackHatSamurai
  • 23,275
  • 22
  • 95
  • 156