【问题标题】:show only one image in carousel slider on mobile在移动设备上的轮播滑块中仅显示一张图像
【发布时间】:2020-01-04 10:39:36
【问题描述】:

我有连续 4 张图片的轮播滑块,在台式机和平板电脑的屏幕尺寸上还可以,但在移动设备上我不想调整图片的大小,我只想在每张幻灯片中显示一个项目。 bootstrap 会自动调整图像大小并显示较小的项目!如何检测手机屏幕尺寸并在每张幻灯片中仅显示一张图片。

我的代码:

<style>
.media-carousel 
{
  margin-bottom: 0;
  padding: 0 40px 30px 40px;
  margin-top: 30px;
}
/* Previous button  */
.media-carousel .carousel-control.left 
{
  left: -12px;
  background-image: none;
  background: none repeat scroll 0 0 #222222;
  border: 4px solid #FFFFFF;
  border-radius: 23px 23px 23px 23px;
  height: 40px;
  width : 40px;
  margin-top: 30px
}
/* Next button  */
.media-carousel .carousel-control.right 
{
  right: -12px !important;
  background-image: none;
  background: none repeat scroll 0 0 #222222;
  border: 4px solid #FFFFFF;
  border-radius: 23px 23px 23px 23px;
  height: 40px;
  width : 40px;
  margin-top: 30px
}
/* Changes the position of the indicators */
.media-carousel .carousel-indicators 
{
  right: 50%;
  top: auto;
  bottom: 0px;
  margin-right: -19px;
}
/* Changes the colour of the indicators */
.media-carousel .carousel-indicators li 
{
  background: #c0c0c0;
}
.media-carousel .carousel-indicators .active 
{
  background: #333333;
}
.media-carousel img
{
  width: 250px;
  height: 100px
}
</style>

  <div class="carousel slide media-carousel" id="media">
    <div class="carousel-inner">
      <div class="item  active">
        <div class="row">
          <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
            <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
          </div>          
          <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
            <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
          </div>  
          <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
            <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
          </div>  
          <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
            <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
          </div>              
        </div>
      </div>
      <div class="item">
        <div class="row">
          <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
            <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
          </div>         
          <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
            <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
          </div>  
          <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
            <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
          </div> 
          <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
            <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
          </div>              
        </div>
      </div>
    </div>
    <a data-slide="next" href="#media" class="right carousel-control">‹</a>
    <a data-slide="prev" href="#media" class="left carousel-control">›</a>
  </div>

桌面预览:

手机预览:

【问题讨论】:

    标签: html css carousel bootstrap-carousel


    【解决方案1】:

    无法使用引导轮播根据屏幕分辨率调整幻灯片,您需要使用外部资源来制作此类困难的滑块。

    这是帮助您制作此类滑块的参考链接。

    滑动滑块: https://kenwheeler.github.io/slick/

    【讨论】:

    • 嘿,这个参考对你有帮助吗?
    • 嗨,我正在寻找可以看到中心卡焦点的东西,它应该比其他三分之二大。我在上面提到的 kenwheeler 链接中看到了一个中心模式,但它并没有满足我的需要。我想展示一些像中心一样的东西。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-25
    • 2018-09-27
    • 2018-05-24
    • 1970-01-01
    • 2018-03-22
    相关资源
    最近更新 更多