Grow your CSS skills. Land your dream job.

How to spread 3 checkboxes evenly across form

  • # July 14, 2013 at 7:19 am

    Hi,
    I’m having some difficulty creating a 3-column checkbox questionnaire thing at the top of my contact form. I’ve wrapped each label/checkbox with a div and tried to use floats to space them evenly across the form but the text keeps dropping down to the next line. [Here’s a link to the problem](http://cdpn.io/vsLng “codepen”). Any help people? Also, not quite sure how to fix the vertical alignment of the left-aligned text with the white input space. Love your thoughts!
    Thanks in advance.
    B

    # July 14, 2013 at 10:02 am

    For one thing your inputs are to wide…

    input {
    width: 470px;
    }

    …is not overridden for checkboxes

    # July 14, 2013 at 10:08 am

    For another you might try switching the order of the input and label in the HTML

    # July 14, 2013 at 10:09 am

    Something like [this](http://cdpn.io/bHwKF “http://cdpn.io/bHwKF”) ?

    # July 14, 2013 at 10:12 am

    No…I meant like this


    # July 14, 2013 at 10:26 am

    @Paulie_D No, I mean’t I had a solution. I tested your solution and it doesn’t seem to work ? (including the input width)

    For my solution, I used `inline-block` instead of floats. Instead of sifting through the code I just put in the necessary resets of rules.

    # July 14, 2013 at 6:48 pm

    Hi georgearnall,

    Thanks for your posts. I also thought to use inline-block but then the alignment goes awry. What I want is for the three checkboxes to be spread _evenly_ across the page. So that the first checkbox (and label) are left aligned, the second is dead center and the third is hard right. Visually that seems to be the best layout. If I float three divs with text I can get them to look exactly right, but when I wrap the label/checkbox combo the two don’t fit on the same line.. Any more suggestions? what am I doing wrong?

    # July 15, 2013 at 5:56 am

    Perhaps you could show us how these checkboxes and labels are **supposed** to look in an image instead of us guessing from a description.

    It would be very helpful.

    # July 15, 2013 at 6:42 am

    Hacky but at least I have the boxes in the right place : http://codepen.io/Paulie-D/pen/HDEJw

    Not sure how you can have a checkbox in the **exact** center or the page **and** a label without it looking pretty lop-sided.

    # July 15, 2013 at 6:52 am

    @bbilander So you mean like [this](http://cdpn.io/HFuCb “http://cdpn.io/HFuCb”) ?

    I think this is as simple as you could make it.

    # July 15, 2013 at 6:54 am

    Slighty better. http://codepen.io/Paulie-D/pen/axhsm

    The top one uses inline-block but requires a change in the source order for checkbox-3

    The bottom one is in the correct source order but the floats mean that some tweaks would have to be made in the positioning.

    # July 15, 2013 at 8:42 am

    Thanks Pauli_D and georgearnall for helping out. The checkboxes need to stay left of the label so the inline-block solution that georgearnall has suggested looks perfect. I’ll give it a go in my design shortly and let you know how it goes.
    CHeers!

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".