Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the function of "overlay" value of "overflow" property? [duplicate]

Tags:

css

overflow

I am unable to understand the difference between "overlay" & "auto". Does "overlay" does the same work as "auto"?

like image 409
Sridhar Avatar asked Mar 27 '17 15:03

Sridhar


People also ask

What does overflow overlay do?

overflow:overlay stops the scroll bar having that effect, in Chrome-based browsers.

What is the correct function of the overflow auto CSS property?

The overflow property specifies what should happen if content overflows an element's box. This property specifies whether to clip content or to add scrollbars when an element's content is too big to fit in a specified area. Note: The overflow property only works for block elements with a specified height.

Which of the following is the value of overflow property?

It can take four different values: Visible: Displays the overflowing content without any modifications – this is the default value of the overflow property. Hidden: Hides the overflowing content. Scroll: Adds vertical and horizontal scroll bars to see the overflowing (hidden) content.

What does overflow mean in CSS?

The overflow CSS shorthand property sets the desired behavior for an element's overflow — i.e. when an element's content is too big to fit in its block formatting context — in both directions.


1 Answers

The only difference is that overflow: overlay is only supported by -Webkit browsers, is non-standardized, and allows the content to extend beneath the scrollbar - whereas overflow: auto will not allow the content to extend beneath the scrollbar, if it appears it'll occupy the space required and shift the content accordingly (either vertically or horizontally).

p {      display: inline-block;      width: 12em;      height: 5em;      border: dotted;  }    p.overflow-auto { overflow: auto; /* append scrollbars if necessary and shift content accordingly to accommodate */ }    p.overflow-overlay { overflow: overlay; /* append scrollbars if necessary and overlay over/above content */ }
<p class="overflow-auto">overflow: auto  Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.</p>    <p class="overflow-overlay">overflow: overlay  Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.</p>

The above snippet demonstrates the difference as follows:

p.overflow-auto { overflow: auto; /* append scrollbars if necessary and shift content accordingly to accommodate */ }  p.overflow-overlay { overflow: overlay; /* append scrollbars if necessary and overlay over/above content */ } 
like image 56
UncaughtTypeError Avatar answered Sep 21 '22 11:09

UncaughtTypeError