在网格中的每列内居中心图像

时间:2018-05-25 14:49:19

标签: css css3 flexbox grid-layout isotope

我正在使用Isotope在Squarespace上创建一个可过滤的图库。我的一切都很完美,但我似乎无法将各个图像集中在列中。任何帮助都会很棒!

每张图片的来源如下所示,样式列在:

之后
<ul class="list">
<li class="list__item cloud connectivity ucaas"><img src="*static url here"/></li> </ul>



ul {
margin-bottom: 1em;
margin: auto;
list-style: none;
display: flex;
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
justify-content: space-between;
}
ul li {
flex: 0 0 auto;
text-align: center;
}

.list { 
margin: 0; 
padding: 0; 
list-style: none; 
}

.list__item {
display: inline-block; 
width: 100%; 
height: 12em;
overflow: hidden;
margin-bottom: 1em;
margin: auto;
text-align: center;
font-size: 1em; 
text-transform: uppercase;
color: white;
}

@media screen and (min-width: 600px) {
.list {
    display: flex;
    flex-wrap: wrap;
  margin: auto;
}
.list__item {
    width: calc(33% - 1em);  
}
@media screen and (min-width: 768px) {

button {
    margin: 0.5em; 
    padding: 0.5em; 
}

.list__item {                               
    width: calc(33% - 1em); 
}

}

1 个答案:

答案 0 :(得分:0)

<ul class="list">
  <li class="list__item cloud connectivity ucaas">
  <div class="cont">

  <img src="http://www.pdfontanaliri.it/wp-content/uploads/2018/01/casa.jpg"/></div></li>
  <li class="list__item cloud connectivity ucaas">
  <div class="cont">
  <img src="http://www.pdfontanaliri.it/wp-content/uploads/2018/01/casa.jpg"/></div></li>
</ul>




.list__item {
width: 100%; 
height: 12em;
overflow: hidden;
margin-bottom: 1em;
margin: auto;
text-align: center;
font-size: 1em; 
text-transform: uppercase;
color: white;

display: flex;
justify-content: center;
align-items: center;
}

.cont {
  height: 50%;
  width: 50%;
  margin: 5px;
  border: 1px solid yellow;
}