开发者

Is it okay to set all divs overflow: hidden?

开发者 https://www.devze.com 2022-12-09 23:51 出处:网络
I guess I\'m wondering if it is ill-advisable to just set: div { overflow: hidden; } ... instead of worrying about clearing each div. Does anyone else do this or recommend for/against it? Thanks.

I guess I'm wondering if it is ill-advisable to just set:

div {
    overflow: hidden;
}

... instead of worrying about clearing each div. Does anyone else do this or recommend for/against it? Thanks.

EDIT:开发者_如何学Go

I only ask because it seems like I have a handful of divs that require it, at the moment.


Yes, that will set overflow: hidden for all divs. If you'll find it wrong for some part of your html, then you can disable it for any divs you'll need like this:

/* use default overflow for all divs in specific element */
#some-element-id div {
    overflow: auto;
}

Or you can use classes for this.


It all depends if you want extra content to be hidden by default. My personal preference is only to hide when I know it won't do any harm. Consider a nav menu. If the user is working on a very small screen and you haven't un-hidden the nav menu overflow specifically, then that user won't be able to navigate.

What it comes down to is which is the worse outcome- broken layout or inaccessible content?

0

精彩评论

暂无评论...
验证码 换一张
取 消