Three divs side by side with spacing in between

前端 未结 5 929
故里飘歌
故里飘歌 2020-12-21 14:04

I\'m trying to have three of divs side by side with spacing in between the div\'s in the middle.

Here is the image of what I need:

Here is my current code:<

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-21 14:59

    What about an easy CSS grid solution:

    .container {
      display: grid;
      grid-gap: 10px;  /* Simply adjust this value !*/
      grid-template-columns: repeat(3, 1fr); /* OR grid-template-columns: 1fr 1fr 1fr;*/
      grid-auto-rows: 1fr;
      border:1px solid green 
    }
    
    .container>div {
      border: 1px solid red;
      height: 20px;
    }

提交回复
热议问题