radio+js实现文字横向幻灯片切换效果代码
代码语言:html
所属分类:其他
代码描述:radio+js实现文字横向幻灯片切换效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> :root { --dark-blue-text: #003781; --dark-blue-bg: #122b54; --light-blue: #f0f7fc; --white: #fff; } .sr-only { border: 0; clip-path: inset(50%); clip: rect(0, 0, 0, 0); height: 1px; margin: 0; overflow: hidden; padding: 0; position: absolute; white-space: nowrap; width: 1px; } *, *:before, *:after { box-sizing: inherit; } html { box-sizing: border-box; font-size: 62.5%; height: 100%; } body { -webkit-font-smoothing: antialiased; align-items: center; background-color: var(--white); color: var(--dark-blue-text); display: flex; display: flex; flex-direction: column; font-family: "Livvic", sans-serif; font-size: 1.6rem; height: 100%; justify-content: flex-start; margin: 0; overflow-x: hidden; padding: 0; line-height: 1.4; } .wrapper { display: flex; flex-direction: column; gap: 1rem; margin: 0 1.6rem; max-width: 144rem; width: 100%; } .my-section { background-color: var(--light-blue); padding: 2rem 0; } .my-section:has(.carousel-item:nth-of-type(1) input[type="radio"]:checked) .top-link--mobile:nth-child(1), .my-section:has(.carousel-item:nth-of-type(2) input[type="radio"]:checked) .top-link--mobile:nth-child(2), .my-section:has(.carousel-item:nth-of-type(3) input[type="radio"]:checked) .top-link--mobile:nth-child(3), .my-section:has(.carousel-item:nth-of-type(4) input[type="radio"]:checked) .top-link--mobile:nth-child(4), .my-section:has(.carousel-item:nth-of-type(5) input[type="radio"]:checked) .top-link--mobile:nth-child(5) { font-weight: bold; } .my-section:has(.carousel-item:nth-of-type(1) input[type="radio"]:checked) .carousel-item:nth-of-type(1) .top-link--desktop::after, .my-section:has(.carousel-item:nth-of-type(2) input[type="radio"]:checked) .carousel-item:nth-of-type(2) .top-link--desktop::after, .my-section:has(.carousel-item:nth-of-type(3) input[type="radio"]:checked) .carousel-item:nth-of-type(3) .top-link--desktop::after, .my-section:has(.carousel-item:nth-of-type(4) input[type="radio"]:checked) .carousel-item:nth-of-type(4) .top-link--desktop::after, .my-section:has(.carousel-item:nth-of-type(5) input[type="radio"]:checked) .carousel-item:nth-of-type(5) .top-link--desktop::after { background-color: var(--dark-blue-text); bottom: 0; content: ""; display: block; height: 2px; left: 0; position: absolute; right: 0; width: 100%; } .top-link { border-bottom: 1px solid var(--dark-blue-text); color: var(--dark-blue-text); cursor: pointer; font-size: 1.4rem; font-weight: bold; margin: 0 0 1.6rem 0; padding: 1rem; text-align: center; text-decoration: none; position: relative; } .top-link--desktop { display: none; width: 100%; } .top-link-wrapper--mobile { -ms-overflow-style: none; display: flex; overflow-x: scroll; padding: 0; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0; scroll-behavior: smooth; } .top-link-wrapper--mobile::-webkit-scrollbar { display: none; } .top-link.top-link--mobile { flex-shrink: 0; font-size: 1.2rem; font-weight: normal; margin: 0; padding: 1rem 2rem; } .top-link--desktop { display: none; } .carousel-fieldset { border: none; margin: 0; max-width: 100%; min-width: 0; padding: 0; position: relative; width: 100%; } .carousel-wrapper { -ms-overflow-style: none; display: flex; margin: 0; max-width: 100%; min-width: 0; overflow-x: scroll; padding: 1.6rem 1.6rem; scroll-behavior: smooth; scroll-snap-type: x mandatory; scrollbar-width: none; width: 100%; } .carousel-wrapper::-webkit-scrollbar { display: none; } .carousel-spacer { background-color: transparent; width: 60rem; flex-shrink: 0; display: none; } .carousel-item { align-items: center; display: flex; flex-directio.........完整代码请登录后点击上方下载按钮下载查看
网友评论0