user1544337
user1544337

Reputation:

CSS selector for a label of which the input is disabled

I have a group of label-input sets of which some sets have a disabled input, and others have a normal input. You can see a basic example in this fiddle.

I want the labels of the normal inputs, to have a pointer cursor, whilst the other labels (of the disabled inputs) should have a default cursor. Is there a pure CSS way to do this? I'd need a selector for "a label which is for a disabled input" or "a label which is for a not-disabled input".

I need this to be flexible, so hardcoding the ids isn't possible (and wouldn't be neat).

Upvotes: 2

Views: 1162

Answers (1)

Marc Lloyd
Marc Lloyd

Reputation: 304

Try this:

input:disabled ~ label{
   cursor:default;
}

The label and input will need a wrapper.

Upvotes: 2

Related Questions