[英]Why do my images get positioned below each other when I set all of them to col-6?
I don't know why my images get positioned below each other even though they are inside a col-6 Bootstrap div. 我不知道为什么即使我的图像都位于col-6 Bootstrap div中,它们也为何彼此位于下方。 I want them to be next to each other, not below.
我希望他们彼此相邻,而不是下方。 Code, in case it's unreadable in the text below: https://imgur.com/S6tSXng
代码,以防下面的文本不可读: https : //imgur.com/S6tSXng
Page: https://imgur.com/7FZl2lM 网页: https : //imgur.com/7FZl2lM
I have already tried putting the col-6 inside the foreach block, but it only made the second image smaller. 我已经尝试过将col-6放在foreach块中,但是它只会使第二张图像变小。 I don't know what else to try.
我不知道还能尝试什么。
<section id="listaoldal">
<div class="container">
<div class="row">
<div class="col-6">
<?php foreach ($characterDetails as $key):?>
<img data-toggle="modal" data-target="#<?= $key['modal']?>" class="img-fluid mx-auto d-block my-5 ddimages"src="characters/<?=$key['link'] ?>">
<?php endforeach;?>
Well, I expect the images to be next to each other like they should be not below. 好吧,我希望这些图像彼此相邻,就像它们不应该位于下方。
在col-6中进行foreach。
<?php foreach ($characterDetails as $key):?> <div class="col-6"><img ... /></div> <?=endforeach?>
<section id="listaoldal">
<div class="container">
<div class="row">
<?php foreach ($characterDetails as $key):?>
<div class="col-6">
<img data-toggle="modal" data-target="#<?= $key['modal']?>" class="img-fluid mx-auto d-block my-5 ddimages"src="characters/<?=$key['link'] ?>">
<?php endforeach;?>
Actually your images are placed into one "col-6" you have to create one for each images, like this: 实际上,您的图像放置在一个“ col-6”中,您必须为每个图像创建一个,例如:
<div class="col-6">
<img .../>
</div>
<div class="col-6">
<img .../>
</div>
<div class="col-6">
<img .../>
</div>
...
Quick exemple of what you could use to make it work : 快速举例说明您可以使用什么来使其工作:
<section id="listaoldal">
<div class="container">
<div class="row">
<?php foreach ($characterDetails as $key):?>
<div class="col-6">
<img data-toggle="modal" data-target="#<?= $key['modal']?>" class="img-fluid mx-auto d-block my-5 ddimages"src="characters/<?=$key['link'] ?>">
</div>
<?php endforeach;?>
I recommend you to read more about Bootstrap's Grid system: https://getbootstrap.com/docs/4.0/layout/grid/ 我建议您阅读有关Bootstrap网格系统的更多信息: https : //getbootstrap.com/docs/4.0/layout/grid/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.