我有一个旋转木马,图像有各种尺寸。我希望这些图像以相同的尺寸显示。通过添加 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.
关于css - 如何在相同大小的轮播中制作图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52914296/