问题
When it comes to starting a new design I always start my style sheet with overruling the browser's default padding and margin on all elements:
* { margin: 0; padding: 0; }
After reading j08691's answer on a margin collapse problem I realized overflow: auto
fixed more than I knew of. I was wondering if it would useful to add overflow: auto
on all elements inside the html
(you don't want to loose the scroll-bar there). So:
html * { overflow: auto; }
I tried adding this rule to one of our sites, and at first glance this works well, but I'm afraid it might break the more exotic elements (that I'm not using now, but might later) and ... Internet Explorer.
Do any of you have experience with a default overflow: auto
? Is it a bad thing to do? Should I opt for a milder version and defining a default overflow: auto
only on div
elements?
回答1:
Yeah, I do think it's bad practice. You should only use it when you don't know whether the content can break the size of an element.
来源:https://stackoverflow.com/questions/12413767/is-setting-overflow-auto-to-all-elements-except-html-bad-practice