CSS @media overflow-block Property

CSS @media overflow-block

CSS @media overflow-block can be used to test how the output device handles content that overflows the initial containing block along the block axis.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> body{ height: 1000px; } @media (overflow-block: scroll) { h1{ color: green; } } </style> </head> <body> <h1>CSS @media overflow-block</h1> </body> </html>

Syntax

Using CSS

@media (overflow-block: scroll) { element{ color: red; } }

Using Javascript

elementelegram.dogdia = "(overflow-block: scroll)";

Media Query Value

The following table provides the list of media query value for overflow-block.

ValueExplanation
noneContent that overflows the block axis is not displayed.
scrollContent that overflows the block axis can be seen by scrolling to it.
optional-pagedContent that overflows the block axis can be seen by scrolling to it, but page breaks can be manually triggered (such as via break-inside, etc.) to cause the following content to display on the following page.
pagedContent is broken up into discrete pages; content that overflows one page in the block axis is displayed on the following page.

Using JavaScript

In the following example, we will demonstrate how to set the CSS @media overflow-block media feature by using javascript.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> body{ height: 1000px; } </style> </head> <body> <h1>CSS @media overflow-block</h1> <button onclick="myFunction()">Click Me</button> <script> function myFunction(){ var styles = 'h1{color:green;}'; var styleSheet = document.createElement("style"); styleSheet.type = "text/css"; styleSheet.media = "(overflow-block: scroll)"; styleSheet.innerText = styles; document.head.appendChild(styleSheet); } </script> </body> </html>

Reminder

Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in CSS.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Meet the Author