Skip to content

Instantly share code, notes, and snippets.

@teethnclaws
Created March 5, 2019 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teethnclaws/6cae0bfe2d431a650a207e59aecb8d2c to your computer and use it in GitHub Desktop.
Save teethnclaws/6cae0bfe2d431a650a207e59aecb8d2c to your computer and use it in GitHub Desktop.
JS Bin flex-direction // source https://jsbin.com/bohateb
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="flex-direction">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.container{
display: flex;
}
.one{
/* default */
flex-direction: row;
}
.two{
flex-direction: row-reverse;
}
.three{
flex-direction: column;
}
.four{
flex-direction: column-reverse;
}
/* basic styling */
.container{
border: 4px solid #61585E;
margin-bottom: 10px;
}
.container > *{
background-color: #EA3556;
padding: 5px;
color: white;
width: 100px;
height: 60px;
}
.container > *:nth-child(even){
background-color: #49AEC0;
}
</style>
</head>
<body>
<!-- BEGIN LESSON CODE -->
<div class="container one">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
<div class="container two">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
<div class="container three">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
<div class="container four">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
<!-- END LESSON CODE -->
<script id="jsbin-source-css" type="text/css">.container{
display: flex;
}
.one{
/* default */
flex-direction: row;
}
.two{
flex-direction: row-reverse;
}
.three{
flex-direction: column;
}
.four{
flex-direction: column-reverse;
}
/* basic styling */
.container{
border: 4px solid #61585E;
margin-bottom: 10px;
}
.container > *{
background-color: #EA3556;
padding: 5px;
color: white;
width: 100px;
height: 60px;
}
.container > *:nth-child(even){
background-color: #49AEC0;
}</script>
</body>
</html>
.container{
display: flex;
}
.one{
/* default */
flex-direction: row;
}
.two{
flex-direction: row-reverse;
}
.three{
flex-direction: column;
}
.four{
flex-direction: column-reverse;
}
/* basic styling */
.container{
border: 4px solid #61585E;
margin-bottom: 10px;
}
.container > *{
background-color: #EA3556;
padding: 5px;
color: white;
width: 100px;
height: 60px;
}
.container > *:nth-child(even){
background-color: #49AEC0;
}
@teethnclaws
Copy link
Author

row (default): left to right in ltr; right to left in rtl
row-reverse: right to left in ltr; left to right in rtl
column: same as row but top to bottom
column-reverse: same as row-reverse but bottom to top

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment