CSS Property: overflow-x
[this page | pdf | back links]
The CSS (CSS2) overflow-x property indicates what to
with left/right edges of content overflowing an element’s box.
Valid property values
(other than inherit
and initial) are:
Value
|
Description
|
auto
|
Overflow is clipped and
a scroll-bar should typically be added
|
hidden
|
Overflow is clipped. No
scroll-bar is added, so rest of content is effectively invisible
|
scroll
|
Overflow is clipped and
a scroll-bar is added
|
visible
|
(default value).
Overflow is not clipped and may be rendered outside the element’s box
|
Default Value:
|
visible
|
JavaScript syntax:
|
e.g. object.style.overflowX="scroll"
|
Inherited:
|
No
|
Animatable:
|
No
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 40px; border: 2px solid red;}
.x1 {overflow-x: scroll}
</style>
</head>
<body>
1. Element with default property<br>
<div>abcdefgh abcdefgh</div><br><br>
2. Element set using in-file HTML style<br>
<div class="x1">abcdefgh abcdefgh</div><br><br>
3. Element set using JavaScript<br>
<div id="x2">abcdefgh abcdefgh</div>
<script>
document.getElementById("x2").style.overflowX = "scroll";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyOverflowX() {
var x = document.createElement("DIV"); x.style.overflowX = "scroll"; return (window.getComputedStyle(x, null).overflowX == "scroll");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties