Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format all labels after a checkbox and radio button with css selector

I have radio buttons and checkboxes with each a label on its right side.

I want to format the label with a margin-left:10px; to have a distant to the radion/check controls.

input[type="checkbox"], input[type="radio"]  label {
    margin-left:10px;
}

This css is moving somehow the whole control + label 10px to the right side...

I just want the left margin on the label.

What do I have to change in my selector?

like image 652
Elisabeth Avatar asked Jun 06 '13 20:06

Elisabeth


2 Answers

input[type="radio"] label is looking for a label that's a child of an input[type=radio] you want:

input[type="radio"] + label

for an adjacent sibling label

like image 110
Matt Berkowitz Avatar answered Nov 07 '22 23:11

Matt Berkowitz


You need to specify them seperately. In your css you have applied the style to input[type="checkbox"] alone also.

Do it like this:

DEMO http://jsfiddle.net/aJPaq/

input[type="checkbox"] + label, input[type="radio"] +  label {
    margin-left:10px;
}
like image 2
Kevin Lynch Avatar answered Nov 07 '22 23:11

Kevin Lynch