js+css实现鼠标滚动控制卡片左右无限滚动效果代码

代码语言:html

所属分类:加载滚动

代码描述:js+css实现鼠标滚动控制卡片左右无限滚动效果代码

代码标签: js css 鼠标 滚动 控制 卡片 左右 无限 滚动

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

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

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


 
 
 
 
<style>
* {
 
box-sizing: border-box;
 
margin: 0px;
 
padding: 0px;
}

html
{
 
font-size: 62.5%;
}

body
{
 
font-family: sans-serif;
 
height: 100vh;
 
 
background: #111;
 
overflow: hidden;
}

.container{
 
height: 100vh;
 
 
width: calc((220px * 3) + 32px);
 
overflow: hidden;
 
margin: 0 auto;
 
position: relative;
}

#wrapper {
 
width: 100%;
 
height: 100vh;
 
 
max-width: calc((220px * 3) + 32px);
 
overflow-x: scroll;
 
display: flex;
 
flex-wrap: nowrap;
 
justify-content: flex-start;
 
align-items: flex-end;
 
gap: 16px;
 
position: relative;
 
padding-top: 12px;
 
padding-left: 0px;
 
padding-right: 220px;
   
scroll-snap-type: x mandatory;
 
scroll-behavior: smooth;
 
scrollbar-width: none;
}

/* 隐藏滚动条 */
#wrapper::-webkit-scrollbar {
   
width: 0; /* 隐藏垂直滚动条 */
   
height: 0; /* 隐藏水平滚动条 */
}
.card {
   
scroll-snap-align: start;
 
flex-shrink: 0;
 
height: 460px;
 
width: 220px;

 
display: flex;
 
flex-direction: column;
 
flex-wrap: wrap;
 
justify-content: space-between;
 
padding: 24px 16px 16px 16px;
 
border: 1px solid black;
 
position: relative;
 
border-radius: 16px;
 
transition: 300ms linear;
 
background: white;
}

.card:hover{
 
transform: translatey(-6px)
}

.card .name {
 
font-size: 1.2rem;
 
font-weight: bold;
 
position: absolute;
 
left: 16px;
 
top: 24px;
   
font-family: 'Roboto Condensed', sans-serif;
 
color: #111;
}

.card .title {
 
font-size: 2.4rem;
 
margin-top: 24px;
 
text-align: left;
 
text-transform: uppercase;
 
font-family: 'Roboto Condensed', sans-serif;
 
font-weight: 700
}

.card .description {
 
font-size: 1.3rem;
 
word-break: break-word;
 
width: 100%;
 
display: flex;
 
line-height: 160%;
}

.card .action {
 
border-radius: 50%;
 
width: 64px;
 
height: 64px;
 
border: 1px solid black;
 
display: flex;
 
justify-content: center;
 
align-items: center;
 
margin: 0 auto;
 
cursor: pointer;
 
transition: 200ms linear;
}


.card .action:hover{
 
background: #000;
}

.card .action:hover svg,
.card .action:hover svg path
{
 
stroke: #fff;
}
</style>

 
 
</head>

<body >
  <link rel="preconnect" href="https://.........完整代码请登录后点击上方下载按钮下载查看

网友评论0