2014-04-28 4 views
0

다음 코드는 파이어 폭스에 아무런 영향이없는 것으로 보인다 다음이 작동하는 동안스타일링 체크 박스의 경우 다른 확인란

input[type="checkbox"] + input[type="checkbox"] { 
    margin-top: 12px; 
    } 

을 :

input[type="checkbox"] { 
    margin-top: 12px; 
    } 

왜?


HTML

<div> 
    <input type="checkbox" name="somename[]" id="somename" value="1"> One<br> 
    <input type="checkbox" name="somename[]" value="2"> Two<br> 
    <input type="checkbox" name="somename[]" value="3"> Three<br> 
    ... 
</div> 
+1

HTML을 제공 할 수 있습니까? 내게 잘 보인다 : http://jsfiddle.net/MyLLZ/ checbox는 다른 요소에 중첩되어서는 안된다. – SW4

+2

은 입력 태그 뒤에
을 가지고 있기 때문에 간단하다. 형제 자매를위한 CSS는 작동하지 않는다. –

+0

Arg, 네, 바보입니다. ! 고마워 :-) 하하! –

답변

0

을 더 인접한 체크 박스가 없기 때문에 귀하의 경우에는

이 개재와 함께 작동 <br> 태그 있습니다 .. <br> 태그입니다 그 경우, <br> 태그는 인접한 형제입니다. 형제 인 <input>을 선택하려면 general sibling selector, ~을 사용해야합니다.

input[type="checkbox"] ~ input[type="checkbox"] { 
    margin-top: 12px; 
} 
2

의 + 선택기 인접 형제 적용하기 때문이다.

input[type="checkbox"] + br + input[type="checkbox"] { 
    margin-top: 12px; 
} 

또는 ~ 선택 사용이에서

input[type="checkbox"] ~ input[type="checkbox"] { 
    margin-top: 12px; 
}