Overflow in CSS
The CSS overflow feature determines how content will display when it is too large for a given frame.
CSS Overflow
The overflow feature indicates whether to cut the content or add a scroll bar to the element's content when it is too large for a predetermined area.It has the following values:
- visible - by default, the overflow is not cut but displayed out of the element box.
- hidden - the overflow is cut and hidden.
- scroll - the overflow is cut but there is a scroll bar to view the rest of the content.
- auto - if the overflow is cut, there is a scroll bar to view the rest of the content.
Note: The overflow feature is only used with block elements that have a predefined height.On OS X Lion, the default scroll bar is hidden, shown only when used.
overflow: visible
By default, overflow is set to visible, meaning that it will not be cut and displayed outside the box.
div {
width : 200px ;
height : 50px ;
background-color : #eee ;
overflow : visible ;
}
The overflow is still displayed
overflow: hidden
When using the hidden value, the overflow will be cut and hidden.
div {
overflow : hidden ;
}
The overflow is hidden behind the predefined size frame
overflow: scroll
When the scroll value is set, the overflow will be cut and placed in a new scroll bar.Note that there will be both horizontal and vertical scroll bars (even if you don't need it).
div {
overflow : scroll ;
}
Scroll bar to see the rest of the content
overflow: auto
The auto value is similar to scroll, only that will add a scroll bar when needed.
div {
overflow : auto ;
}
overflow-x and overflow-y
Overflow-x and overflow-y properties are used to determine whether the overflow will be displayed horizontally, vertically or both.
div {
overflow-x : hidden ; /* Hide horizontal scrollbar */
overflow-y : scroll ; /* Add vertical scrollbar */
}
Previous article: Location of elements in CSS
Lesson: Float in CSS
You should read it
- How to fix text overflow in Google Sheets
- How to fix table errors in Word overflow
- How to set the scroll bar to always show on macOS
- Techniques to exploit buffer overflows: Organize memory, stack, call functions, shellcode
- Types of data hiding in Excel - Part 2: How to hide cells, overflow text
- Expand or collapse the scroll bar in Windows XP
- Macromedia Flash - Create text frames with scroll bars in Flash 8.0
- The power of the Scroll key
May be interested
- The prototype shows that the Galaxy S10 has a screen overflow design, almost no bezel borderthis is samsung galaxy s10, please be quiet and save money.
- Samsung introduced 4 new infinity display technologies, no 'rabbit ears'at sdc 2018 event this morning, beside the new oneui interface, folding screen phone, samsung also introduced 4 new display technologies of the company including 2 drops of water, 1 mole and 1 completely border overflow.
- See YouTube to overflow the browser windowthe article shares tips on watching youtube in full-screen browser mode instead of full screen.
- How to enlarge the window in OS X El Capitan does not overflow the screennormally the screen magnification mode on the mac will be in overflow mode. however, sometimes you want to zoom in on users' preferences without having to be in full screen mode to switch to traditional zoom mode.
- Invite to admire the iPhone 2019 concept, high forehead, no rabbit ears, spill bottom like Bphone 3youtube phone industry channel owner, one of those who do not like to design iphone rabbit ear screen has created an extremely unique iphone 2019 concept with screen without rabbit ears, bottom overflow, high forehead to put speakers, front camera and sensor.
- How to cook porridge with a rice cooker does not overflow?you already know how to cook porridge with rice cooker just fast but not overflow yet? the following article will guide you to cook porridge with an easy-to-use electric rice cooker.
- What is the screen of infinity? Does it resemble the overflow screen?infinity screens have brought about changes in design as well as features of entertainment and multitasking on smartphones.
- Future phones will have screens on both the front and backa patent appeared again showing three new ideas of samsung, two fronts of the phone have screens.
- Vsmart Active 3 image series, with 'peek-in' camerayesterday, some pictures of a strange smartphone bearing the vsmart logo with the front camera 'peeking out', the overflow screen has suddenly been spread online, making many people feel interesting.
- Programmers automate their work and only have to work 2 hours a week but dare not disclose to their bosslast week, programmers had a lively discussion about work ethics when silently automating their work, after a person posted this question on the stack overflow page.