Of course, there are tablet devices that could use sticky elements at some places, but tablet devices are rarely used (2.52% as of September 2021). If some sticky elements won't work on Safari for iOS (13.83%) then that's not that big of a deal, since it's uncommon to use sticky elements on mobile devices anyways (except for maybe the header). If this is something that you prefer over manually wrapping all elements that overflow the viewport, then that is completely understandable. If you do not feel like wrapping every single element that overflows the viewport, and you find it okay if sticky elements won't work on some specific modern browsers, then I suggest using hidden as a fallback for browsers that do not support overflow: clip.Įlements with position: sticky will, in this case, not work for browsers that do not support overflow: clip. Use overflow: hidden as a fallback for overflow: clip If those wrappers contain elements that use position: sticky, then I feel sorry for you I guess it's time to wait for support. Then, those wrappers should use overflow: hidden. If you really want position: sticky to work on all modern browsers, then you should consider not using overflow: hidden on the or any wrapper surrounding the main content, but rather put a wrapper around elements that will overflow the viewport. Your viewport, that is the default scroll container. So, the clip value does not make it a scroll container, so the window is still the scroll container. It hides the overflowing content, but does not turn the element into a scroll container. Mozilla Firefox versions 80 and lower have a non-standard name for value clip, which perfectly describes what it actually does: -moz-hidden-unscrollable. You did not specify a height to the scroll container, and why would you? Since it is now a scroll container, it needs a specified height in order for position: sticky to work. The hidden value only disables scrolling for the user, while keeping the option for programmatic scrolling, thus making it a scroll container. The clip value does the same as the hidden value, except for that it completely disables any form of scrolling. If you are interested in improving the performance of your web design, consider reading a post about lazy-rendering using content-visibility: auto and contain-intrinsic-size. It has no way to determine whether to clip on the x-axis or the y-axis, unlike you can with overflow-x and overflow-y with value clip. So that's a slight improvement compared to overflow.Īlso, contain is a CSS property that is used for improving performance, not necessarily for controlling overflow of content. It has been around in Google Chrome since version 52, though. Sadly, this CSS property is also not supported by Safari. If you use contain: paint, then all the descendants that overflow the container, will get clipped to the border-box. There is, however, another rather new CSS property: contain.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |