如何制作一个可在悬停时扩展的flexbox,使其在移动设备上具有滚动选项?我正在寻找的示例包括

时间:2018-06-25 18:36:14

标签: css flexbox bootstrap-4

我有一个横幅,其中并排有5张图片,每张图片都展开以在悬停时显示更多文字。但是在移动设备上很难阅读,所以我想知道是否有一种方法可以像Foo Fighters网站(https://foofighters.com/)一样添加滚动效果

我试图避免使用滚动条,而是使用左右箭头。

该网站建立在引导程序4上。

$sql = "SELECT * FROM videos ORDER BY video_id ASC LIMIT 2,1";
#container-banner {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 75vh;
  width: 100vw;
}

#container-banner:hover>.section {
  -webkit-filter: brightness(22%);
  filter: brightness(22%);
}

#container-banner:hover>.section:hover {
  -webkit-filter: brightness(100%);
  filter: brightness(100%);
}

#container-banner .section {
  flex-grow: 1;
  position: relative;
  height: 100%;
  transition: all 0.4s;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  text-align: center;
  flex: 1;
}

#container-banner .section .cont_title {
  position: relative;
  margin: auto;
  width: 100%;
  height: auto;
  text-align: center;
  margin-top: 37vh;
}

#container-banner .section .cont_title h1 {
  text-transform: uppercase;
  color: white;
  font-family: 'Economica', sans-serif;
  text-shadow: 1px 2px 5px rgba(0, 0, 0, 0.5);
  font-size: 3.5vw;
  margin: 0;
  transition: font-size 0.3s;
  vertical-align: middle;
}

#container-banner .section .cont_title h3 {
  text-transform: uppercase;
  font-family: 'Economica', sans-serif;
  font-size: 1.3vw;
  transition: all 0.3s;
  color: white;
  letter-spacing: 3px;
  text-shadow: 1px 2px 5px rgba(0, 0, 0, 0.5);
}

#container-banner .section .cont_desc {
  position: relative;
  display: block;
  text-align: center;
  width: 12vw;
  height: auto;
  margin: auto;
  opacity: 0;
  transition: opacity 0.8s, padding-top 0.9s, -webkit-transform 0.7s;
  transition: opacity 0.8s, transform 0.7s, padding-top 0.9s;
  transition: opacity 0.8s, transform 0.7s, padding-top 0.9s, -webkit-transform 0.7s;
  padding-top: 6vh;
  -webkit-transform: scale(1);
  transform: scale(1);
}

#container-banner .section .cont_desc p {
  margin: 0;
  font-family: 'Economica', sans-serif;
  color: white;
  font-size: 16px;
}

#container-banner .section:hover {
  flex-grow: 1.8;
  transition: flex 0.2s;
}

#container-banner .section:hover>.cont_title h1 {
  font-size: 5.3vw;
  transition: font-size 0.4s;
}

#container-banner .section:hover>.cont_title h3 {
  font-size: 1.6vw;
  transition: all 0.4s;
}

#container-banner .section:hover>.cont_desc {
  opacity: 1;
  padding-top: 2vh;
  -webkit-transform: scale(1.5);
  transform: scale(1.5);
  transition: opacity 0.7s, padding-top 0.5s, -webkit-transform 0.1s;
  transition: opacity 0.7s, padding-top 0.5s, transform 0.1s;
  transition: opacity 0.7s, padding-top 0.5s, transform 0.1s, -webkit-transform 0.1s;
  transition-delay: 0s, 0.1s, 0s;
}

#container-banner .section:nth-child(1) {
  background: url("../img/members/2nd-round.jpg") center;
}

#container-banner .section:nth-child(2) {
  background: url("../img/members/3rd-round.jpg") center;
}

#container-banner .section:nth-child(3) {
  background: url("../img/HRBAlbumCover.svg") center;
  object-fit: cover;
  -webkit-background-size: contain;
  background-size: contain;
  background-color: black;
}

#container-banner .section:nth-child(4) {
  background: url("../img/members/3.jpg") center;
}

#container-banner .section:nth-child(5) {
  background: url("../img/members/4.jpg") center;
  object-fit: cover;
}

1 个答案:

答案 0 :(得分:0)

您是否使用过名为owl.carouselhttps://owlcarousel2.github.io/OwlCarousel2的jquery库?它是一个了不起的库,可让您轻松创建支持触摸和拖动的轮播滑块,这在移动设备中至关重要。

在小型设备上

enter image description here

宽于600像素

enter image description here

宽于1000像素

enter image description here

您可以完全自定义每个断点要显示多少个项目:

$(function(){
    $("#banner").owlCarousel({
    loop: true,
    margin: 10,
    nav: true,
    responsive: {
        0: {
        items: 2
      },
      600: {
        items: 3
      },
      1000: {
        items: 5
      }
    }
  });
});

本来可以给导航箭头更多的爱,但是您可以根据需要完全设置它们的样式。

中部链接:http://jsfiddle.net/xpvt214o/324749/