The following example shows the result of using the center value:
HTML file: | Displayed by browser: |
---|---|
<style>
.flex-container { display: -webkit-flex; display: flex; -webkit-justify-content: center; justify-content: center; width: 400px; height: 250px; background-color: lightgrey; } .flex-item { background-color: cornflowerblue; width: 100px; height: 100px; margin: 10px; } </style> <body> <div class="flex-container"> <div class="flex-item">flex item 1</div> <div class="flex-item">flex item 2</div> <div class="flex-item">flex item 3</div> </div> <p>The flex-line, with all flex-items positioned on it, is centered within the flex-container.</p> </body> |
flex item 1
flex item 2
flex item 3
The flex-line, with all flex-items positioned on it, is centered within the flex-container. |