纯css手风琴 选项卡 轮播 图像


<div class="container">
  <h1>Gallery</h1>

  <div class="gallery-wrap">
    <div class="item item-1"></div>
    <div class="item item-2"></div>
    <div class="item item-3"></div>
    <div class="item item-4"></div>
    <div class="item item-5"></div>
  </div>
 </div>



-------------------------------------



html, body {
  width: 100%;
  height: 100%;background-color: #1F1F1F;
}

.container {
  padding: 75px 0;
  margin: 0 auto;
  width: 1140px;
}

h1 {
  position: relative;
  margin-bottom: 45px;
  font-family: "Oswald", sans-serif;
  font-size: 44px;
  text-transform: uppercase;
  color: #424242;
}

.gallery-wrap {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 70vh;
}

.item {
  flex: 1;
  height: 100%;
  background-position: center;
  background-size: cover;
  background-repeat: none;
  transition: flex 0.8s ease;
}
.item:hover {
  flex: 7;
}

.item-1 {
  background-image: url("https://images.unsplash.com/photo-1499198116522-4a6235013d63?auto=format&fit=crop&w=1233&q=80");
}

.item-2 {
  background-image: url("https://images.unsplash.com/photo-1492760864391-753aaae87234?auto=format&fit=crop&w=1336&q=80");
}

.item-3 {
  background-image: url("https://images.unsplash.com/photo-1503631285924-e1544dce8b28?auto=format&fit=crop&w=1234&q=80");
}

.item-4 {
  background-image: url("https://images.unsplash.com/photo-1510425463958-dcced28da480?auto=format&fit=crop&w=1352&q=80");
}

.item-5 {
  background-image: url("https://images.unsplash.com/photo-1503602642458-232111445657?auto=format&fit=crop&w=1234&q=80");
}




  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
jQuery手风琴图片轮播切换是一种常用的网页图片轮播效果,可以让网页内容更加生动,增强用户体验。手风琴效果是指在图片轮播时,当前图片会被放大,其他图片则会被压缩。以下是该效果的实现步骤: 1. HTML结构:创建一个包含所有图片的容器和一个包含所有小圆点的容器。 2. CSS样式:为容器和小圆点添加样式,设置图片的宽度、高度和位置。 3. JavaScript代码:实现图片轮播的逻辑。通过jQuery获取容器和小圆点,为小圆点添加点击事件,点击后切换到对应的图片,并给当前图片添加类名,其他图片则移除类名,实现手风琴效果。 以下是一个示例代码: HTML: ``` <div class="slider"> <div class="slider-wrapper"> <img src="img1.jpg" alt=""> <img src="img2.jpg" alt=""> <img src="img3.jpg" alt=""> </div> <div class="dots"> <span></span> <span></span> <span></span> </div> </div> ``` CSS: ``` .slider { width: 100%; height: 500px; position: relative; } .slider-wrapper { width: 100%; height: 100%; position: relative; } .slider-wrapper img { width: 100%; height: 100%; position: absolute; top: 0; left: 0; transition: all 0.5s ease-in-out; } .slider-wrapper img.active { transform: scale(1.2); } .dots { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); } .dots span { display: inline-block; width: 10px; height: 10px; margin-right: 10px; background-color: #ccc; border-radius: 50%; cursor: pointer; } .dots span.active { background-color: #f00; } ``` JavaScript: ``` $(function(){ var $slider = $('.slider'), $wrapper = $('.slider-wrapper'), $imgs = $('.slider-wrapper img'), $dots = $('.dots span'), len = $imgs.length, index = 0; // 初始化 $imgs.eq(0).addClass('active'); $dots.eq(0).addClass('active'); // 点击事件 $dots.on('click', function(){ var idx = $(this).index(); if(idx !== index){ $imgs.eq(index).removeClass('active'); $dots.eq(index).removeClass('active'); $imgs.eq(idx).addClass('active'); $dots.eq(idx).addClass('active'); index = idx; } }); }); ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

破裤兜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值