css Checkbox Label Selector

Posted by HW90 on Stack Overflow See other posts from Stack Overflow or by HW90
Published on 2012-08-26T20:12:47Z Indexed on 2012/08/31 15:39 UTC
Read the original article Hit count: 248

I'm developing a MVC3 application and need to select the checkboxes label.

In ASP MVC3 you have helper methods which creat a part of the code. So the code for a checkbox looks like this:

<input id="Jumping_successleicht" type="checkbox" value="true" name="Jumping_successleicht">
<input type="hidden" value="false" name="Jumping_successleicht">
<label for="Jumping_successleicht">
<span>leicht (4)</span>
</label>

Now I've thought I can use following code to select the label:

input[type=checkbox] + label {
    background: url("../../Images/Controls/Checkbox.png") no-repeat scroll left center transparent;
    clear: none;
    cursor: pointer;
    margin: 0;
    padding: 5px 0 4px 24px;
}

But it does not work. It looks like label and input have to be next to each other.

Does any ony have a solution how to solve this problem?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about css