style.css
setup.css
index.html
section {
display: flex;
height: 120px;
}
section:nth-child(2) div {
flex-grow: 1; /* All grow equally. */
}
section:nth-child(3) div:nth-child(1) {
background-color: hotpink;
flex-grow: 1; /* Just grow this one. */
}
section:nth-child(4) div:nth-child(1) {
background-color: hotpink;
flex-grow: 1;
}
section:nth-child(4) div:nth-child(2) {
background-color: crimson;
flex-grow: 2; /* Grow twice as much. */
}
section:nth-child(5) div {
width: 50%; /* With 3 `div` would be 150%. */
}
section:nth-child(5) div:nth-child(1) {
background-color: lightsalmon;
flex-shrink: 0; /* Don’t shrink this one! */
}
body {
font-family: sans-serif;
padding: 20px;
}
div {
background-color: tomato;
border-bottom: 2px solid firebrick;
border-right: 2px solid firebrick;
padding: 5px;
}
section {
background-color: gold;
}
section:not(:first-child) {
margin-top: 20px;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/assets/styles/reset.css" rel="stylesheet">
<link href="setup.css" rel="stylesheet">
<link href="style.css" rel="stylesheet">
</head>
<body>
<section>
<div>
<p>Item 1</p>
</div>
<div>
<p>Item 2</p>
</div>
<div>
<p>Item 3</p>
</div>
</section>
<section>
<div>
<p>Item 1</p>
</div>
<div>
<p>Item 2</p>
</div>
<div>
<p>Item 3</p>
</div>
</section>
<section>
<div>
<p>Item 1</p>
</div>
<div>
<p>Item 2</p>
</div>
<div>
<p>Item 3</p>
</div>
</section>
<section>
<div>
<p>Item 1</p>
</div>
<div>
<p>Item 2</p>
</div>
<div>
<p>Item 3</p>
</div>
</section>
<section>
<div>
<p>Item 1</p>
</div>
<div>
<p>Item 2</p>
</div>
<div>
<p>Item 3</p>
</div>
</section>
</body>
</html>