html – How to make inline-flex background fit from its content


.flex-container {
  display: inline-flex;
  flex-wrap: wrap;
  background-color: DodgerBlue;
}

.flex-container > div {
  background-color: #f1f1f1;
  width: 100px;
  margin: 5px;
  text-align: center;
  line-height: 75px;
  font-size: 30px;
}
<!DOCTYPE html>
<html>
  <body>

    <div class="flex-container">
      <div>1</div>
      <div>2</div>
      <div>3</div>  
      <div>4</div>
      <div>5</div>
      <div>6</div>  
      <div>7</div>
      <div>8</div>
    </div>

  </body>
</html>



Source link

Latest articles

Related articles

Leave a reply

Please enter your comment!
Please enter your name here