简体   繁体   English

当我将所有图像都设置为col-6时,为什么我的图像彼此位于较低的位置?

[英]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.

相关问题 为什么在single.php中过滤每个帖子的每个标题 - Why do I get every title of each post when I filter them in single.php 尝试从数据库中获取图像时,为什么我的图像没有出现 - Why is my images not appearing, when trying to get them from database 我如何将图像彼此相邻放置而不会破裂 - How do I put the images next to each other without them breaking 为什么即使我设置了maxresults,我仍然使用Google BigQuery的PHP库获得所有行? - Why do I get all rows with the PHP library for Google BigQuery, even when I set maxresults? 当我将它们保存为.HTML文件时,我的PrettyPhoto图像会变形。 - My PrettyPhoto images get distorted when I save them as an .HTML File 当我在webservice中调用一个操作时,为什么会出现此错误“falseObject reference not set to a object of object。” - Why do I get this error “falseObject reference not set to an instance of an object.” when I call an operation in my webservice 为什么我会收到以下代码的偏移错误? - Why do I get an offset error for the code below? 我如何让我的自定义字段仅在其中写入了某些内容时才显示-Wordpress? - How do I get my custom fields to only show when something is written in them - Wordpress? Tinymce echo 图像彼此相邻而不是下方 - Tinymce echo Images next to each other instead below 如何在 PHP 中显示即将到来的交替星期四,并让它们每周不互相覆盖 - How do I display the upcoming alternating Thursdays in PHP and have them not overwrite each other each week
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM