The justify-content
property
is a property of the Flexible Box Layout.
The justify-content
property defines
the alignment and distribute extra space.
justify-content: flex-start|flex-end|center|space-between|space-around|initial|inherit;
justify-content |
Yes | 11.0 | Yes | Yes | Yes |
<!DOCTYPE html>
<html>
<style>
.flex-container {<!-- w ww.j a v a 2s. c o m-->
padding: 0;
margin: 0;
list-style: none;
-ms-box-orient: horizontal;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -moz-flex;
display: -webkit-flex;
display: flex;
}
.flex-start {
-webkit-justify-content: flex-start;
justify-content: flex-start;
}
.flex-end {
-webkit-justify-content: flex-end;
justify-content: flex-end;
}
.flex-end li {
background: gold;
}
.center {
-webkit-justify-content: center;
justify-content: center;
}
.center li {
background: deepskyblue;
}
.space-between {
-webkit-justify-content: space-between;
justify-content: space-between;
}
.space-between li {
background: lightgreen;
}
.space-around {
-webkit-justify-content: space-around;
justify-content: space-around;
}
.space-around li {
background: hotpink;
}
.flex-item {
background: red;
padding: 5px;
width: 60px;
height: 50px;
margin: 5px;
line-height: 50px;
color: white;
}
</style>
</head>
<body>
<ul class="flex-container flex-start">
<li class="flex-item">1</li>
<li class="flex-item">2</li>
<li class="flex-item">3</li>
<li class="flex-item">4</li>
<li class="flex-item">5</li>
</ul>
<ul class="flex-container flex-end">
<li class="flex-item">1</li>
<li class="flex-item">2</li>
<li class="flex-item">3</li>
<li class="flex-item">4</li>
<li class="flex-item">5</li>
</ul>
<ul class="flex-container center">
<li class="flex-item">1</li>
<li class="flex-item">2</li>
<li class="flex-item">3</li>
<li class="flex-item">4</li>
<li class="flex-item">5</li>
</ul>
<ul class="flex-container space-between">
<li class="flex-item">1</li>
<li class="flex-item">2</li>
<li class="flex-item">3</li>
<li class="flex-item">4</li>
<li class="flex-item">5</li>
</ul>
<ul class="flex-container space-around">
<li class="flex-item">1</li>
<li class="flex-item">2</li>
<li class="flex-item">3</li>
<li class="flex-item">4</li>
<li class="flex-item">5</li>
</ul>
</body>
</html>