Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i nest the disabled attribute using LESS?

Tags:

html

css

less

I have the following code to target buttons that are in a disable state:

.btn-default[disabled] {
  background-color: lighten(@btn-default-bg, 30%)
}

Is it possible to use nested rules to target the disabled attribute? something similar to &:Hover

like image 653
Jack Murphy Avatar asked Nov 27 '13 22:11

Jack Murphy


People also ask

Are disabled attribute inside input is an used?

Definition and Usage A disabled input element is unusable and un-clickable. The disabled attribute can be set to keep a user from using the <input> element until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the <input> element usable.

How do you make a Div disabled using CSS?

To disable div element and everything inside with CSS, we set the pointer-events CSS property of the div to none . to disable pointer events on the div with pointer-events set to none with CSS.

How do I add a disabled attribute to a tag?

There is no disabled attribute like this (<a href="#" disabled>) for "a" tag. you can try disabling using css so just add class in your "a" tag & then disable using css.


1 Answers

You can indeed, like this:

.btn-default {
  &[disabled] {
    background-color: lighten(@btn-default-bg, 30%)
  }
}

http://jsbin.com/aKuLire/1/edit

You can even do further nesting:

input {
  &[type="submit"] {
    &[disabled] {
      background: @blue;
    }
  }
}
like image 138
davidpauljunior Avatar answered Nov 08 '22 16:11

davidpauljunior