简体   繁体   English

div元素没有并排放置的问题

[英]Problem with div element not position side by side

I have a code in blade.php that need to show images.我在blade.php 中有一个需要显示图像的代码。 Ideally, the images should stack side by side with div element.理想情况下,图像应该与 div 元素并排堆叠。 But it seems not working.但它似乎不起作用。

I tried flex , bootstrap and float .我试过flexbootstrapfloat Use display in html element.在 html 元素中使用display

 .lightbox img { width: 100%; margin-bottom: 30px; transition: .2s ease-in-out; box-shadow: 0 2px 3px rgba(0, 0, 0, .2); max-height: 198px; display: flex; object-fit: cover; }
 <link rel="stylesheet" href="{{ asset('css/app.css') }}"> @foreach($post as $post) <div class="row pt-5"> <div class="col-sm-6 col-md-4"> <a class="lightbox" href="/storage/{{ $post}}"> <img src="/storage/{{ $post }}" class="w-25"> </a> </div> </div> @endforeach

Here is current view-it show up and down images这是当前视图 - 它显示上下图像

Changing position of your @foreach may help:更改@foreach位置可能会有所帮助:

<link rel="stylesheet" href="{{ asset('css/app.css') }}">
    <div class="row pt-5">
      @foreach($post as $post)
        <div class="col-sm-6 col-md-4">
            <a class="lightbox" href="/storage/{{ $post}}">
                <img src="/storage/{{ $post }}" class="w-25">
            </a>
        </div>
      @endforeach
    </div>

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

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