原生js实现电商购物车滚动粘性浮动效果代码
代码语言:html
所属分类:电商
代码描述:原生js实现电商购物车滚动粘性浮动效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/reset.min.css"> <style> html { --space: 2rem; --space-xs: calc(var(--space) / 3); --space-sm: calc(var(--space) / 2); --space-md: calc(var(--space) * 2); --color-primary: lightgray; --color-accent: whitesmoke; --color-dark: black; --color-mid: gray; --color-light: white; --color-highlight: dodgerblue; --radius: 0.125rem; } /* Here are the base styles for the main layout and sticky component */ * { box-sizing: border-box; } main { display: flex; flex-wrap: wrap; } .article { flex-basis: 0; flex-grow: 999; min-width: 40%; } .sidebar { --offset: var(--space); flex-grow: 1; flex-basis: 300px; align-self: start; position: -webkit-sticky; position: sticky; top: var(--offset); } .component { display: grid; grid-template-rows: auto 1fr auto; } .component .content { max-height: 500px; overflow-y: auto; } .sidebar .component { max-height: calc(100vh - var(--offset) * 2); } /* * Other styles **/ .visually-hidden { clip: rect(0 0 0 0); -webkit-clip-path: inset(50%); clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; } html, body { height: 100%; } [hidden] { display: none; } body { margin: 0 auto; padding: 0 var(--space); font-family: "Helvetica Neue", sans-serif; font-size: 1.25rem; line-height: 1.4; max-width: 1400px; } h2 { font-size: clamp(2rem, 4vw, 3.5rem); font-weight: 600; line-height: 1.2; } p { max-width: 70ch; font-size: clamp(1rem, 4vw, 1.25rem); } header, footer { display: flex; align-items: center; justify-content: center; margin: var(--space-md) 0; padding: var(--space); height: 40vh; background: repeating-linear-gradient( 45deg, transparent, transparent 12px, var(--color-accent) 12px, var(--color-accent) 24px ); } /* Until flexbox gap is supported in all modern browsers, we use the negative margin trick to create space between the children elements */ main {.........完整代码请登录后点击上方下载按钮下载查看
网友评论0