w3resource
HTML exercises

CSS Properties: How to the second flex-item grow three times wider than the rest?

Go to Exercise page

Solution:

HTML Code:

<!DOCTYPE html>
<html>
<head>
<title>How to the second flex-item grow three times wider than the rest</title>
<style type="text/css">
#w3r {
  width: 400px;
  height: 100px;
  border: 1px solid #FF00FF;
  display: -webkit-flex;
  display: flex;
}
#w3r div:nth-of-type(1) {-webkit-flex-grow: 1;}
#w3r div:nth-of-type(2) {-webkit-flex-grow: 3;}
#w3r div:nth-of-type(3) {-webkit-flex-grow: 1;}
#w3r div:nth-of-type(4) {-webkit-flex-grow: 1;}
#w3r div:nth-of-type(5) {-webkit-flex-grow: 1;}
#w3r div:nth-of-type(1) {flex-grow: 1;}
#w3r div:nth-of-type(2) {flex-grow: 3;}
#w3r div:nth-of-type(3) {flex-grow: 1;}
#w3r div:nth-of-type(4) {flex-grow: 1;}
#w3r div:nth-of-type(5) {flex-grow: 1;}
</style>
</head>
<body>
<p><strong>w3resource Tutorial</strong></p>
<div id="w3r">
<div style="background-color:#00FF00;">HTML5</div>
<div style="background-color:#3333FF;">CSS</div>
<div style="background-color:#FF6600;">PHP</div>
<div style="background-color:#FF3399;">SQL</div>
<div style="background-color:#FFCC33;">MYSQL</div>
</body>
</html>

Live Demo:

See the Pen flex-grow-answer by w3resource (@w3resource) on CodePen.


See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
Yes Yes Yes Yes No

Go to Exercise page

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming