Is setting overflow: auto to all elements except html bad practice?

99封情书 提交于 2020-02-07 03:36:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!