Open In App

HTML | DOM Style flexFlow Property

Improve
Improve
Like Article
Like
Save
Share
Report

The Style flexFlow property in HTML DOM is used to specify the value for two different properties flexDirection property and flexWrap property. The flexDirection property is used to specify the direction of flexible items and flexWrap property is used to specify the flexible item should wrap or not. 

Syntax:

  • It returns the string which represents the flexFlow property of an element.
object.style.flexFlow
  • It is used to set the flexFlow property value.
object.style.flexFlow = "flex-direction flex-wrap|initial|
inherit"

Return Values: It returns a string that represents the flex-flow property of an element

Property Values:

1. flex-direction flex-wrap: The flewFlow property is the combination of flexDirection and flexWrap property. The default value of flex-direction flex-wrap is row nowrap. Following are the list of possible values of flexDirection and flexWrap properties.

flex-direction = "row |row-reverse |column |column-reverse |
initial |inherit";
flex-wrap = "nowrap |wrap |wrap-reverse |initial |inherit";

Example 1: It changes the flexFlow property value from “row wrap” to “column wrap”. 

html




<!DOCTYPE html>
<html>
     
<head>
    <title>
        HTML DOM Style flexFlow Property
    </title>
     
    <style>
        #GFG {
            width: 220px;
            height: 150px;
            border: 2px solid black;
             
             /* For Safari browsers */
            display: -webkit-flex;
             
             /* For Safari 6.1+ browsers  */
            -webkit-flex-flow: row wrap;
            display: flex;
            flex-flow: row wrap;
        }
        #GFG div {
            width: 50px;
            height: 70px;
        }
    </style>
</head>
 
<body>
    <div id="GFG">
        <div style="background-color:lightgreen;">G</div>
        <div style="background-color:green;">E</div>
        <div style="background-color:lightgreen;">E</div>
        <div style="background-color:green;">K</div>
        <div style="background-color:lightgreen;">S</div>
    </div>
     
    <button onclick="myGeek()">
        Click Here
    </button>
     
    <script>
        function myGeek() {
             
            /* For Safari Browsers */
            document.getElementById("GFG").style.WebkitFlexFlow
                    = "column wrap";
             
            document.getElementById("GFG").style.FlexFlow
                    = "column wrap";
        }
    </script>
</body>
 
</html>                   


Output: 

Before click on the button:

  

After click on the button: 

Example 2: It changes the flexFlow property value from “row wrap” to “row-reverse wrap-reverse”. 

html




<!DOCTYPE html>
<html>
     
<head>
    <title>
        HTML DOM Style flexFlow Property
    </title>
     
    <style>
        #GFG {
            width: 220px;
            height: 150px;
            border: 2px solid black;
             
             /* For Safari browsers */
            display: -webkit-flex;
             
             /* For Safari 6.1+ browsers  */
            -webkit-flex-flow: row wrap;
            display: flex;
            flex-flow: row wrap;
        }
        #GFG div {
            width: 50px;
            height: 70px;
        }
    </style>
</head>
 
<body>
    <div id="GFG">
        <div style="background-color:lightgreen;">G</div>
        <div style="background-color:green;">E</div>
        <div style="background-color:lightgreen;">E</div>
        <div style="background-color:green;">K</div>
        <div style="background-color:lightgreen;">S</div>
    </div>
     
    <button onclick="myGeek()">
        Click Here
    </button>
     
    <script>
        function myGeek() {
             
            /* For Safari Browsers */
            document.getElementById("GFG").style.WebkitFlexFlow
                    = "row-reverse wrap-reverse";
             
            document.getElementById("GFG").style.FlexFlow
                    = "row-reverse wrap-reverse";
        }
    </script>
</body>
 
</html>                   


Output: 

Before click on the button:

  

After click on the button:

 

2. initial: It set the flexFlow property to its default value. 

Example 3: 

html




<!DOCTYPE html>
<html>
     
<head>
    <title>
        HTML DOM Style flexFlow Property
    </title>
     
    <style>
        #GFG {
            width: 220px;
            height: 150px;
            border: 2px solid black;
             
             /* For Safari browsers */
            display: -webkit-flex;
             
             /* For Safari 6.1+ browsers  */
            -webkit-flex-flow: row wrap;
            display: flex;
            flex-flow: row wrap;
        }
        #GFG div {
            width: 50px;
            height: 70px;
        }
    </style>
</head>
 
<body>
    <div id="GFG">
        <div style="background-color:lightgreen;">G</div>
        <div style="background-color:green;">E</div>
        <div style="background-color:lightgreen;">E</div>
        <div style="background-color:green;">K</div>
        <div style="background-color:lightgreen;">S</div>
    </div>
     
    <button onclick="myGeek()">
        Click Here
    </button>
     
    <script>
        function myGeek() {
             
            /* For Safari Browsers */
            document.getElementById("GFG").style.WebkitFlexFlow
                    = "initial";
             
            document.getElementById("GFG").style.FlexFlow
                    = "initial";
        }
    </script>
</body>
 
</html>                   


Output: 

Before click on the button:

  

After click on the button:

 

3. inherit: It inherits the property from its parent element. 

Example 4: 

html




<!DOCTYPE html>
<html>
     
<head>
    <title>
        HTML DOM Style flexFlow Property
    </title>
     
    <style>
        #GFG {
            width: 220px;
            height: 150px;
            border: 2px solid black;
             
             /* For Safari browsers */
            display: -webkit-flex;
             
             /* For Safari 6.1+ browsers  */
            -webkit-flex-flow: row wrap;
            display: flex;
            flex-flow: row wrap;
        }
        #GFG div {
            width: 50px;
            height: 70px;
        }
    </style>
</head>
 
<body>
    <div id="GFG">
        <div style="background-color:lightgreen;">G</div>
        <div style="background-color:green;">E</div>
        <div style="background-color:lightgreen;">E</div>
        <div style="background-color:green;">K</div>
        <div style="background-color:lightgreen;">S</div>
    </div>
     
    <button onclick="myGeek()">
        Click Here
    </button>
     
    <script>
        function myGeek() {
             
            /* For Safari Browsers */
            document.getElementById("GFG").style.WebkitFlexFlow
                    = "inherit";
             
            document.getElementById("GFG").style.FlexFlow
                    = "inherit";
        }
    </script>
</body>
 
</html>                   


Output: 

Before click on the button:

  

After click on the button:

 

Supported Browsers: The browser supported by DOM Style flexFlow property are listed below:

  • Google Chrome 29 and above
  • Edge 12 and above
  • Internet Explorer 11.0 and above
  • Firefox 28 and above
  • Opera 12.1 and above
  • Safari 9 and above


Last Updated : 09 Aug, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads