简体   繁体   English

调整网站大小时,图像不会在一起

[英]Images don't stay together when I resize website

I make a website with 3 images side by side. 我制作一个并排有3张图片的网站。 I actually wanted to get those 3 games centered in the middle of the website, but I don't quite get on how to get it done, so I'm okay for now. 我实际上想将这3款游戏放在网站中间,但是我还不太了解如何完成它,所以我现在还可以。

But now when I RESIZE the website the images they change positions. 但是现在当我调整网站大小时,它们会改变位置。

I tried to fix this without success. 我试图解决此问题,但没有成功。

Does anyone know how to fix this? 有谁知道如何解决这一问题?

 html { width: 100%; } body { background: url(achtergrondimage.png); width: 100%; } .home2 { margin: 0 auto; width: 49.7%; text-align: center; background-color: yellow; height: 400px; float: left; } .center { margin-bottom: 0px; margin-top: 200px; margin-left: 225px; width: 40%; padding: 20px; height: 300px; float: left; align-content: center; vertical-align: top; } .homefarcry img { margin: 10px; padding: 0px; float: left; width: 30%; display: inline-block; border: solid 1px; align-content: center; vertical-align: top; border-style: solid; } .homefifa18 img { margin: 10px; padding: 0px; width: 30%; float: left; display: inline-block; border: solid 1px; align-content: center; vertical-align: top; border-style: solid; } .homeoverwatch img { margin: 10px; padding: 0px; width: 30%; float: left; display: inline-block; border: solid 1px; align-content: center; vertical-align: top; border-style: solid; } 
 <div class="center"> <div class="homefarcry"> <div class="farcry5"> <img src="https://images-na.ssl-images-amazon.com/images/I/91j3CuFDMiL._SL1500_.jpg" alt="farcry 5" style="float: left;width: 30%; margin-right: 1%;margin-bottom: 1em" /> </div> </div> <div class="homefifa18"> <div class="fifa18"> <img src="https://resources.budgetgaming.nl/boxarts/118979_fifa18ps4kopen.jpg" alt="fifa18" style="float: left; width: 30%; margin-right: 1%;margin-bottom: 1em" /> </div> </div> <div class="overwatch"> <div class="homeoverwatch"> <div> <img src="http://i.ebayimg.com/00/s/MTUwMFgxMTk2/z/5p8AAOSw65FXuyoV/$_57.JPG?set_id=8800005007" alt="OverWatch" style="float: left; width: 30%;margin-right: 1%;margin-bottom: 1em"> </div> </div> </div> </div> 

html {
  height: 100%;
  width: 100%;
}

body {
  background: url(achtergrondimage.png);
  width: 100%;
}

.img-container {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
}

.img-container img {
  width: 70px;
  height: 90px;
  margin: 5px;
}

This should align them to the center while making sure they never break on the next line. 这应该使它们与中心对齐,同时确保它们不会在下一行中断。

I used flexbox and justify-content: center on .img-container to align them to the center and flex-wrap: nowrap so they don't break 我使用了flexbox和justify-content:在.img-container上居中以将它们与居中对齐并进行flex-wrap:nowrap以便它们不会破裂

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM