无法使对象在div的底部对齐

时间:2018-10-10 16:03:57

标签: html css alignment

我试图显示五行图像,并以不同比例在底部对齐。我有合适的尺寸,但是由于某种原因,我尝试使它们位于底部的所有方法均无效。缩放比例是正确的,但我只是不能让他们坐在最下面。我试过了float,vertical align,position,bottom:0px ...残端..我是否需要将其包装在另一个div中??

感谢您的帮助!

    <html>

<style>
.photos {
  width: 100%;
  line-height: 0;
  -webkit-column-count: 5;
  -webkit-column-gap:   0px;
  -moz-column-count:    5;
  -moz-column-gap:      0px;
  column-count:         5;
  column-gap:           0px;
  height: 500px;
  float: bottom;
}

.one {
  width: 40% !important;
  height: auto !important;
  object-fit:     fill;
  float: bottom;
}

.two {
  width: 70% !important;
  height: 500px !important;
  object-fit: scale-down;
}

.four {
  width: 65% !important;
  height: 500px !important;
  object-fit: scale-down;
}

.six {
  width: 95% !important;
  height: 500px !important;
  object-fit: scale-down;
}

.eight {
  width: 95% !important;
  height: 500px !important;
  object-fit: scale-down;
}

</style>

<div class="photos">

<img class="one" src="https://cdn.shopify.com/s/files/1/0088/3094/3290/files/One_10_editors_award_e72e0a9f-af53-4d5a-a7ff-ad43529a292e.PNG?16373459996811127802">

<img class ="two" src="https://cdn.shopify.com/s/files/1/0088/3094/3290/files/TWO-10-500sq.png?16128425807283382807">

<img class="four" src="https://cdn.shopify.com/s/files/1/0088/3094/3290/files/FOUR-10-800-colour-corrected-800.png?161284258072833828077">

<img class="six" src="https://cdn.shopify.com/s/files/1/0088/3094/3290/files/Six_main_WEB.jpg?16128425807283382807">


<img class="eight" align="botoom" src="https://cdn.shopify.com/s/files/1/0088/3094/3290/files/EIGHT-10.png?16128425807283382807">

</div>

1 个答案:

答案 0 :(得分:0)

我认为可以使用display:flex属性来很好地适应您的情况。

将.photo类设置为flex容器,如下所示:

.photo {  align-items: flex-end ; }

然后向.photo类添加align属性,以为其所有直接子级设置align:

.one{  align-self: flex-end; }

.two{  align-self: flex-end; }

或者如果要在每个类上分别添加,请使用css属性align-self

l = ['table']
i = []

...等

更多信息:https://css-tricks.com/snippets/css/a-guide-to-flexbox/