CSS Property: flex-direction
[this page | pdf | back links]
The CSS (CSS3) flex-direction property indicates the direction
of a flexible element. If an element is not a flexible element then this
property has no effect.
Valid property values
(other than inherit
and initial) are:
Value
|
Description
|
column
|
Items are displayed
vertically, as a column
|
column-reverse
|
Items are displayed
vertically, but in reverse order
|
row
|
(default value). Items
are displayed horizontally, as a row
|
row-reverse
|
Items are displayed
horizontally, but in reverse order
|
Default Value:
|
row
|
JavaScript syntax:
|
e.g. object.style.flexDirection="column"
|
Inherited:
|
No
|
Animatable:
|
No
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
.x1 {display: flex; flex-direction: column;}
</style>
</head>
<body>
1. Element with default property<br>
<div style="display: flex;">
<div>text 1</div><div>text 2</div><div>text 3</div>
</div>
<br>
2. Element set using in-file HTML style<br>
<div class="x1">
<div>text 1</div><div>text 2</div><div>text 3</div>
</div>
<br>
3. Element set using JavaScript<br>
<div id="x2">
<div>text 1</div><div>text 2</div><div>text 3</div>
</div>
<br>
<script>
document.getElementById("x2").style.display = "flex";
document.getElementById("x2").style.flexDirection = "column";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyFlexDirection() {
var x = document.createElement("DIV"); x.style.flexDirection = "column"; return (window.getComputedStyle(x, null).flexDirection == "column");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties