Grow your CSS skills. Land your dream job.

2 anchors in a div: center the first, offset the 2nd

  • # April 27, 2009 at 8:58 am

    I’d like to have a horizontally centered header logo (which links to "/") and to the right of it another anchor which I’ll use for displaying help text. The idea is to have my site’s logo with an asterisk (*) next to it that can be clicked for more info.

    I have no problem performing this but the entire div is centered making the logo slightly off-center. Here is my code so far:

    html:

    Code:

    *

    css:

    Code:
    #title {
    width: 400px;
    margin-left: auto;
    margin-right: auto;
    }

    This obviously doesn’t work as it centers the entire div, but I just want to center the first anchor and have the second anchor next to it. Any ideas?

    # April 27, 2009 at 10:27 am

    Float your logo to the left.

    # April 27, 2009 at 4:08 pm

    Add this:

    Code:
    #title img{
    float:left;
    }

    Ashton

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

You must be logged in to reply to this topic.

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