简体   繁体   English

如何在 CSS 中将同一图像类的多个副本彼此相邻放置?

[英]How can I place multiple copies of the same image class next to each other in CSS?

I am trying to make a flappy bird type game where there will be a row of identical spikes on the bottom of the page.我正在尝试制作一个飞扬的鸟类型游戏,页面底部会有一排相同的尖峰。 I copy and pasted the image for the spikes 20 times but now I want to use CSS to place all the spike images right next to each other and be on the bottom of the page.我将尖峰的图像复制并粘贴了 20 次,但现在我想使用 CSS 将所有尖峰图像彼此相邻放置并位于页面底部。 Does anyone know how to do this?有谁知道如何做到这一点?

    <img class = 'spike1' src = 'spike.png'>

Use display flex?使用显示弹性?

 .spikes { display: flex } .spikes img { height: 50px; width: 50px }
 <div class="spikes"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> <img src="spike.png"> </div>

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

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