css - 如何在相同大小的轮播中制作图像?

标签 css laravel bootstrap-4 styles

我有一个旋转木马,图像有各种尺寸。我希望这些图像以相同的尺寸显示。通过添加 height 解决了这个问题,但是 carousel 失去了它的响应能力(当你从移动设备进入时)。这是我的轮播代码:

<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
              <div class="carousel-inner">
              @foreach($lastPosts as $key => $last)
                <div class="item @if($key == 0) active @endif">
                  <!-- post -->
                                    <div class="post post-thumb">
                                        <a class="post-img" href="/{{ $last->category->path }}/post/{{ $last->id }}"><img src="./img/posts/{{ $last->image->name }}" class="img-responsive d-block w-100" alt=""></a>
                                        <div class="post-body">
                                            <div class="post-category">
                                                <a href="/{{ $last->category->path }}">{{ $last->category->name }}</a>
                                            </div>
                                            <h3 class="post-title title-lg"><a href="/{{ $last->category->path }}/post/{{ $last->id }}">{{ $last->title }}</a></h3>
                                            <ul class="post-meta">
                                                <li>{{ \Carbon\Carbon::parse($last->date)->format('d '.$months[date('n')].' Y') }}</li>
                                            </ul>
                                        </div>
                                    </div>
                                    <!-- /post -->
                </div>
                @endforeach

              </div>
            </div>

我该如何解决这个问题?

最佳答案

你试过 bootstrap img-fluid 吗?

Images in Bootstrap are made responsive with .img-fluid. max-width: 100%; and height: auto; are applied to the image so that it scales with the parent element.

https://getbootstrap.com/docs/4.1/content/images/

关于css - 如何在相同大小的轮播中制作图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52914296/

相关文章:

html - Bootstrap 可折叠菜单无法打开

html - 悬停效果不会调整我的按钮

html - 将 'point zero' 添加到嵌套 css 计数器的第一级

html - 绝对定位不会溢出到另一个div

jquery 显示是否来自特定链接

html - 在不设置固定大小的情况下,如何强制 ul 中的所有 li 元素与最大项的大小相同?

php - MySQL SELECT 查询获取记录如果 is_default = 1 否则 is_default = 0?

laravel - 在现有应用程序中安装 Laravel 身份验证

html - 最后在超大屏幕中的 hr 行

Laravel - 使用哪个缓存驱动程序?