- This topic is empty.
September 12, 2013 at 4:09 pm #149887nixnerdParticipant
I’m working on a particularly complex layout… not in terms of aesthetics, just code.
I experimented with different ways to do a wrapper but I find that less goes wrong when I just give elements a margin-right or a margin-left, depending on what side they’re on. Is this foolish? Must I have a wrapper? Or can I individually control everything on the page to make it all in the middle?
I know this is more labor intensive but it may be my only choice.September 12, 2013 at 7:22 pm #149905
Is a wrapper really necessary?
It depends on whether it is really necessary.
I’m not being a smartmouth – seriously, it’s necessary for some layouts, but not for others. There’s no way to answer that question in absolute terms.
If you have a particular layout in mind, and would like to share it, I’d be happy to help you figure it out.September 12, 2013 at 10:10 pm #149913sadunareshParticipant
its NECESSARY if you want to create a clean and manageable layout.September 12, 2013 at 11:17 pm #149917
@JoshWhite – For managing basic document styles (e.g., width and margins), you can style the
body. There’s no need to wrap everything with another element.
The only thing I’ve ever found a wrapper (meaning, a whole-layout wrapper) necessary for is certain “sticky footer” implementations (before I found this, that is). Now, I’m not saying that you can do “anything” without a wrapper – but many things have a wrapper-less solution.
Sometimes individual modules/ layout components will need a wrapper. But even where a wrapper is required, there is often a way to use a “natural” element as the wrapper – removing the need for an extra element. (After all, any discrete content should already be marked up in some sectioning element.)
@sadunaresh – I disagree that wrappers make layouts “clean” and “manageable” – in fact, I submit that they do the opposite. They create clutter. If there’s “no other way,” fine; but you should be looking for another way.
@Taufik – don’t “forget about box-sizing”! It’s just about the only thing IE got right. Sizing most elements as “
border-box” solves a lot of problems, not the least of which is all the complicated calculations you mention with padding and border size. It is also just about universally available – all major browsers from IE8 on up, and IE7- use the border-box model in the first place.September 13, 2013 at 3:00 am #149939SenffParticipant
Well…. if you want a background image/color on the full page, and the contents have a fixed/maximum width and need to be centered, then you’d need a wrapper: http://codepen.io/anon/pen/dbutk
Even though, technically you could just set the background on the HTML element and then center/space the BODY. So then you wouldn’t need one: http://codepen.io/anon/pen/dKEiB
But then the idea is the same.September 13, 2013 at 5:11 am #149953sadunareshParticipant
by “WRAPPER” if you mean page level wrapper I agree you can add width, margin, css etc on BODY tag…
but for any other sub-sections or callouts or panes in the page… I think you cannot easily manage all their contents/children individually.
So, group them and play with them…
but many things have a wrapper-less solution.
I believe there are only a few … like add width, margin, css etc on BODY tag
I submit that they do the opposite. They create clutter.
I agree only if you are referring to meaningless or redundant mark up in HTML
If there’s “no other way,” fine; but you should be looking for another way.
I didn’t mean “no other way,” there are ways which end up in extra CSS when you have different no of different elements to accommodate in a section…September 13, 2013 at 5:22 am #149955Paulie_DMember
Can we just leave it at…NO, a wrapper isn’t necessary…until it is?September 15, 2013 at 12:12 pm #150154
- The forum ‘CSS’ is closed to new topics and replies.