Grow your CSS skills. Land your dream job.

How do you write CSS for it?

  • # May 9, 2013 at 9:57 am

    Hi, whenever I write css for this http://codepen.io/sayed2x2/pen/DaprL, I always think that, there must be a better way of doing it, so I thought lets ask this today on forum.
    1. How do you manage to get rid of the margin of the last element when you have already set the margin of the all divs(inline or something because last-child isn’t supported in all browsers)?
    2.Do you add a clearfix div for each container where items are floating inside because , if I dont, it wouldn’t take the background of the man container and will also have problem setting margins.

    Thanks.

    # May 9, 2013 at 10:38 am

    Use margin-left and set it to 0 on :first-child.

    # May 9, 2013 at 11:29 am

    If it’s all on one line, I’ll use the margin-left method as @CrocoDillon mentioned. If things are spread onto multiple lines, I actually just created a codepen for another thread that answer that with a little trick: http://codepen.io/ggilmore/pen/bbd121b060400333d6ce7d886c47bbe6

    # May 9, 2013 at 11:48 am

    Thanks doc , the I didn’t know this overflow:hidden trick, that solves my second problem. But if you give a background color to the wrapper, there still is a 5px margin on the right , how would you remove that? I can do margin-left method, but is there any other way to do it without first-child set to 0?

    # May 9, 2013 at 11:50 am

    >I can do margin-left method, but is there any other way to do it without first-child set to 0?

    Yes there are but this one has the best browser support.

    # May 9, 2013 at 12:17 pm

    Okay got it thanks a lot.

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

You must be logged in to reply to this topic.

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