div+css实现水平自适应响应式滚轮驱动图片列表滚动效果代码

代码语言:html

所属分类:响应式

代码描述:div+css实现水平自适应响应式滚轮驱动图片列表滚动效果代码

代码标签: div css 水平 自适应 响应式 滚轮 驱动 图片 列表 滚动

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
  
<style>
:root {
  overscroll-behavior: none;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body { background-color: black; }

.slider {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 95vw;
  overflow: hidden;
  scrollbar-width: none;

  &::-webkit-scrollbar { -webkit-appearance: none; }

  & .slider-track {
    width: max-content;
    display: flex;
    gap: 0.5rem;
    height: 60vmin;
    will-change: transform;
    
    & .card {
      aspect-ratio: 3/2;
      background-size: cover;
      background-position: center;

      &:nth-of-type(1) { background-image: url('//repo.bfw.wiki/random/800x600/景色?rand=1'); }
      &:nth-of-type(2) { background-image: url('//repo.bfw.wiki/random/800x600/景色?rand=18'); }
      &:nth-of-type(3) { background-image: url('//repo.bfw.wiki/random/800x600/景色?rand=17'); }
      &:nth-of-type(4) { background-image: url('//repo.bfw.wiki/random/800x600/景色?rand=16'); }
      &:nth-of-type(5) { background-image: url('//repo.bfw.wiki/random/800x600/景色?rand=15'); }
      &:nth-of-type(6) { background-image: url('//repo.bfw.wiki/random/800x600/景色?rand=14'); }
      &:nth-of-type(7) { background-image: url('//repo.bfw.wiki/random/800x600/景色?rand=13'); }
      &:nth-of-type(8) { background-image: url('//repo.bfw.wiki/random/800x600/景色?rand=12'); }
      &:nth-of-type(9) { background-image: url('//repo.bfw.wiki/random/800x600/景色?rand=11'); }
 .........完整代码请登录后点击上方下载按钮下载查看

网友评论0