CSS3 Flexbox: Flex-Wrap: Wrap

The wrap value will wrap the flex-items if necessary. The following example shows the result of using the wrap value:

HTML file: Displayed by browser:
<style>
.flex-container {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    width: 300px;
    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-items stay the specified size and will wrap if the flex-container is not wide enough.</p>
</body>
flex item 1
flex item 2
flex item 3

The flex-items stay the specified size and will wrap if the flex-container is not wide enough.


Back button Table of Contents Next button