Format all labels after checkbox and radio button with css selector

I have radio buttons and checkboxes with each label on the right.

I want to format the label with the left margin: 10px; have remote control radio / control.

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

This css somehow moves the whole control + 10px label to the right ...

I just need the left margin on the shortcut.

What do I need to change in my selector?

+6
source share
2 answers

input[type="radio"] label searches for the label that you need a child of input[type=radio] :

 input[type="radio"] + label 

for the adjacent brother label

+14
source

You need to specify them separately. In your css, you applied the style only to input[type="checkbox"] .

Do it like this:

DEMO http://jsfiddle.net/aJPaq/

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

Source: https://habr.com/ru/post/946723/


All Articles