Created
March 5, 2019 02:24
-
-
Save teethnclaws/abce2ea6c2e457db7508fc52384c9893 to your computer and use it in GitHub Desktop.
JS Bin align-items // source https://jsbin.com/lahurew
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="align-items"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
.container{ | |
display: flex; | |
min-height: 100px; | |
} | |
.one{ | |
/* default */ | |
align-items: stretch; | |
} | |
.two{ | |
align-items: flex-start; | |
} | |
.three{ | |
align-items: flex-end; | |
} | |
.four{ | |
align-items: center; | |
} | |
.five{ | |
align-items: baseline; | |
} | |
/*basic styling*/ | |
.container{ | |
border: 4px solid #61585E; | |
margin-bottom: 10px; | |
} | |
.container > *{ | |
background-color: #EA3556; | |
padding: 5px; | |
color: white; | |
width: 100px; | |
} | |
.container > *:nth-child(even){ | |
background-color: #49AEC0; | |
} | |
</style> | |
</head> | |
<body> | |
<!-- BEGIN LESSON CODE --> | |
<div class="container one"> | |
<div>1<br>-<br>-</div> | |
<div>2<br>-<br>-<br>-</div> | |
<div><h2>3</h1></div> | |
<div>4<br>-</div> | |
</div> | |
<div class="container two"> | |
<div>1<br>-<br>-</div> | |
<div>2<br>-<br>-<br>-</div> | |
<div><h2>3</h1></div> | |
<div>4<br>-</div> | |
</div> | |
<div class="container three"> | |
<div>1<br>-<br>-</div> | |
<div>2<br>-<br>-<br>-</div> | |
<div><h2>3</h1></div> | |
<div>4<br>-</div> | |
</div> | |
<div class="container four"> | |
<div>1<br>-<br>-</div> | |
<div>2<br>-<br>-<br>-</div> | |
<div><h2>3</h1></div> | |
<div>4<br>-</div> | |
</div> | |
<div class="container five"> | |
<div>1<br>-<br>-</div> | |
<div>2<br>-<br>-<br>-</div> | |
<div><h2>3</h2></div> | |
<div>4<br>-</div> | |
</div> | |
<!-- END LESSON CODE --> | |
<script id="jsbin-source-css" type="text/css">.container{ | |
display: flex; | |
min-height: 100px; | |
} | |
.one{ | |
/* default */ | |
align-items: stretch; | |
} | |
.two{ | |
align-items: flex-start; | |
} | |
.three{ | |
align-items: flex-end; | |
} | |
.four{ | |
align-items: center; | |
} | |
.five{ | |
align-items: baseline; | |
} | |
/*basic styling*/ | |
.container{ | |
border: 4px solid #61585E; | |
margin-bottom: 10px; | |
} | |
.container > *{ | |
background-color: #EA3556; | |
padding: 5px; | |
color: white; | |
width: 100px; | |
} | |
.container > *:nth-child(even){ | |
background-color: #49AEC0; | |
}</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container{ | |
display: flex; | |
min-height: 100px; | |
} | |
.one{ | |
/* default */ | |
align-items: stretch; | |
} | |
.two{ | |
align-items: flex-start; | |
} | |
.three{ | |
align-items: flex-end; | |
} | |
.four{ | |
align-items: center; | |
} | |
.five{ | |
align-items: baseline; | |
} | |
/*basic styling*/ | |
.container{ | |
border: 4px solid #61585E; | |
margin-bottom: 10px; | |
} | |
.container > *{ | |
background-color: #EA3556; | |
padding: 5px; | |
color: white; | |
width: 100px; | |
} | |
.container > *:nth-child(even){ | |
background-color: #49AEC0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
stretch (default): stretch to fill the container (still respect min-width/max-width)
flex-start: cross-start margin edge of the items is placed on the cross-start line
flex-end: cross-end margin edge of the items is placed on the cross-end line
center: items are centered in the cross-axis
baseline: items are aligned such as their baselines align