好的,两件事:
#1 Materialize已经有了一个响应式图片类:
// Images
img.responsive-img,
video.responsive-video {
max-width: 100%;
height: auto;
}
在globals.scss文件中的第156-162行。
https://materializecss.com/media-css.html
无论如何,当我刚刚检查了CodePen时,图片都是全宽的。我从图像本身中删除了额外的img-responsive声明和类,并且在Chrome中仍然可以正常工作。
https://codepen.io/doughballs/pen/XWbmvbE
#2 Materialize使用背景图像作为其滑块
Materialize滑块仅使用图像标签获取图像的src,然后将其应用于img标签的背景中。因此,img-responsive无关紧要。以下是全屏幻灯片演示的实际代码:
<ul class="slides">
<li class="" style="opacity: 0.0568148; transform: translateX(0px) translateY(0px);">
<img src="data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" style="background-image: url("https://images.unsplash.com/photo-1464817739973-0128fe77aaa1?dpr=1&auto=compress,format&fit=crop&w=1199&h=799&q=80&cs=tinysrgb&crop=");"> <!-- random image -->
<div class="caption center-align" style="opacity: 0.0568148; transform: translateY(-94.3185px);">
<h3>This is our big Tagline!</h3>
<h5 class="light grey-text text-lighten-3">Here's our small slogan.</h5>
</div>
</li>
<li class="active" style="opacity: 0.943185; transform: translateX(0px) translateY(0px);">
<img src="data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" style="background-image: url("https://ununsplash.imgix.net/photo-1414849424631-8b18529a81ca?q=75&fm=jpg&s=0e993004a2f3704e8f2ad5469315ccb7");"> <!-- random image -->
<div class="caption left-align" style="opacity: 0; transform: translateX(-100px) translateY(0px);">
<h3>Left Aligned Caption</h3>
<h5 class="light grey-text text-lighten-3">Here's our small slogan.</h5>
</div>
</li>
<li style="opacity: 0; transform: translateX(0px) translateY(0px);" class="">
<img src="data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" style="background-image: url("https://ununsplash.imgix.net/uploads/1413259835094dcdeb9d3/6e609595?q=75&fm=jpg&s=6a4fc66161293fc4a43a6ca6f073d1c5");"> <!-- random image -->
<div class="caption right-align" style="opacity: 0; transform: translateX(100px);">
<h3>Right Aligned Caption</h3>
<h5 class="light grey-text text-lighten-3">Here's our small slogan.</h5>
</div>
</li>
</ul>
如果你深入研究CSS,就会发现它已经强制图片全宽显示:
.slider .slides li img {
height: 100%;
width: 100%;
background-size: cover;
background-position: center;
}