Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS first-child issue

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #39422
    cybershot
    Participant

    I have four columns in my page structured like so




















    I created a css rule to spread them out with 28px left margin. I need the first one to have zero left margin. So I tried


    #content .columns:first-child {
    margin-left: 0;
    }

    It’s not working. How can I select that first div that will work cross browser?

    #108015
    TheDoc
    Member

    Your first child has a class name of ‘column’, not ‘columns’. That’s why it’s not working.

    #108107
    TheDoc
    Member

    It should be working fine. Do you have a link? Or even pasting the exact code could help.

    Remember that when using first-child the element you are selecting must be the actual first child of your #content container. For example, if you had a header tag before the first .columns div, .columns:first-child will never be true.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.