How to create a 3 column image grid using html and css? [closed]

醉酒当歌 提交于 2019-12-25 08:01:53

问题


I am interested to know what is the best practice to create an image grid similar to the image attached using HTML and CSS.

Thanks.


回答1:


You would use CSS flex container like so.

Here is sample CSS:

.flex-container {
  flex-direction:row;
  display: -webkit-flex;
  display: flex;
  background-color: grey;
  width: 100%;
  height: 100px;
  align-content: center;
  flex-flow: row wrap; 
}

.flex-item {
  background-color: lightblue;
  width: 40%;
  height: 100px;
  margin: 10px;
  order: 1;  
}

Here is sample HTML to go with it:

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

You will need to take this technique and apply it your circumstances.



来源:https://stackoverflow.com/questions/42077309/how-to-create-a-3-column-image-grid-using-html-and-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!