Link to home
Start Free TrialLog in
Avatar of tangteng78
tangteng78Flag for Malaysia

asked on

Checkbox and label not indented properly

Just need to get the checkbox and label to be on the same line and indented properly.

Any help is greatly appreciated :)

See the code:

<head runat="server">
    <title></title>

    <style type="text/css">
        #cbRedeem {
        display: none;
        }
        #cbRedeem + label
        {
            float: left;
            width: 50px;
            height: 50px;
            background: url('Image/Control/checkbox_unchecked.jpg');
            background-repeat: no-repeat;
   
        }
        #cbRedeem:checked + label  
        {
            float: left;
            width: 50px;
            height: 50px;
            background: url('Image/Control/checkbox_checked.jpg');
            background-repeat: no-repeat;
        }    
    </style>

</head>
<body>
   
    <form id="form1" runat="server">
   
    <asp:CheckBox ID="cbRedeem" runat="server" Text="blah blah blah" Checked="false" AutoPostBack="true" Font-Bold="true" />
    <label for="cbRedeem"></label><br />
   
    </form>
</body>
checkbox-not-indented.jpg
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

You should really post your rendered code and not your asp code.  If there is an error in your rendered code, you can always figure out how to back that out.

Without any css, everything lines up.  Perhaps you can post a link to your sample page to look at.

Also, make sure you are applying your css to classes and not id's. There can only be one ID but you can have multiple classes.  I am not a .NET dev, but it seems a lot of people programming in .NET tend to repeat ID's and that can play havoc with your front end code.

http://jsbin.com/dujino/1/edit
<!DOCTYPE html>
<html>
<head>
  <style type="text/css">
    
    </style>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <form id="form1">
    
    <input type="checkbox" ID="cbRedeem" Text="blah blah blah"/>
    <label for="cbRedeem">blah blah blah</label>
    <br />
    <input type="checkbox" ID="cbRedeem" Text="blah blah blah"/>
    <label for="cbRedeem">blah blah blah</label>
    <br />
    <input type="checkbox" ID="cbRedeem" Text="blah blah blah"/>
    <label for="cbRedeem">blah blah blah</label>
    <br />
    </form>
</body>
</html>

Open in new window

Avatar of tangteng78

ASKER

Just checked. There is no repeated ids.

Here you go the actual page http://www.toypanic.com/testing1.aspx

Believe the culprit is the CSS. If someone able to help, it would be great.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A) You seem to have two labels for the checkbox - one in the <span> and one after it
You can probably remove the following line from your source.
  <label for="cbRedeem"></label><br />

Open in new window

Right on.