- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
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.
Use margin-left and set it to 0 on :first-child.
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
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?
>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.
Okay got it thanks a lot.