mercredi 7 novembre 2018

How to horizontally stretch elements when using flex-box

I am trying to strech inner objects horizontally so they will fill the width of their container.

here is my code:

<!DOCTYPE html>
<html>
<head>
<style>
.flex-container {
  display: flex;
  height: 200px;
  align-items: stretch;
  background-color: DodgerBlue;
}

.flex-container > div {
  background-color: #f1f1f1;
  margin: 10px;
  text-align: center;
  line-height: 75px;
  font-size: 30px;
}
</style>
</head>
<body>
<h1>The align-items Property</h1>

<p>The "align-items: stretch;" stretches the flex items to fill the container (this is default):</p>

<div class="flex-container">
  <div>1</div>
  <div>2</div>
  <div>3</div>  
</div>

</body>
</html>

The height of the inner div elements streched thanks to the property:

align-items: stretch;

How to stretch the width of these elements too?




Aucun commentaire:

Enregistrer un commentaire