css+js实现横向图文列表卡片可拖动滚动控制效果代码
代码语言:html
所属分类:拖放
代码描述:css+js实现横向图文列表卡片可拖动滚动控制效果代码
代码标签: css js 横向 图文 列表 卡片 拖动 滚动 控制
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter&display=swap" rel="stylesheet">
<style>
:root {
--accent: rgb(212, 255, 0);
--accent-hover: rgb(190, 228, 0);
--accent-active: #72d534;
--control: #49aa00;
--secondary: #ECEFEB;
--secondary-hover: #E0E4DE;
--secondary-active: #6c6c6b;
--headline-color: rgba(100, 105, 150, 1);
--event-text: rgba(29, 32, 59, 1);
--success: rgba(80, 189, 85, 1);
--error: rgba(232, 113, 113, 1);
--white: rgba(255, 255, 255, 1);
--accent-text: #163300;
}
body {
padding: 16px;
display: flex;
height: 100vh;
min-width: 320px;
font-family: "Inter", sans-serif;
}
* {
box-sizing: border-box;
}
.top-bar {
display: flex;
gap: 16px;
align-items: center;
width: 100%;
flex-direction: row;
color: var(--headline-color);
}
.top-bar h2 {
font-size: 1.2rem;
font-weight: 700;
line-height: 1.5rem;
}
.top-bar svg {
color: var(--headline-color);
}
.action-buttons {
position: relative;
display: inline-flex;
flex: 0 0 auto;
gap: 0.5rem;
scroll-snap-align: start;
width: 100%;
flex-wrap: wrap;
}
.action-button {
color: var(--accent-text);
border-radius: 1rem;
height: 2rem;
gap: 0.25rem;
cursor: pointer;
display: flex;
padding: 0 0.75rem;
font-weight: 600;
transition: all 0.2s ease-in-out;
white-space: nowrap;
align-items: center;
text-decoration: none;
background: var(--secondary);
}
.action-button--primary:active {
background: var(--accent-active);
}
.action-button:active {
background: var(--secondary-active);
}
.action-button--horizontal-scroll {
border-radius: 50%;
cursor: pointer;
border: none;
outline: none;
width: 2rem;
height: 2rem;
background: var(--accent);
}
.action-button--horizontal-scroll:hover {
background: var(--accent-hover);
}
.action-button--horizontal-scroll:active {
background: var(--accent-active);
}
.action-button--horizontal-scroll:disabled {
cursor: not-allowed;
background: var(--secondary);
}
.action-button--horizontal-scroll:disabled:hover {
background: var(--secondary);
}
.action-button--horizontal-scroll:disabled:active {
background: var(--secondary);
}
#action-button--previous {
margin-left: auto;
transform: rotate(-90deg);
}
#action-button--next {
transform: rotate(90deg);
}
.action-button:hover {
background: var(--secondary-hover);
}
.action-button--primary {
background: var(--accent);
}
.action-button--primary:hover {
background: var(--accent-hover);
}
.action-button--primary:active {
background: var(--accent-active.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0