首页:修订间差异
来自SOKA CAFE
| 第33行: | 第33行: | ||
<title>自适应轮播图</title> | <title>自适应轮播图</title> | ||
<style> | <style> | ||
/* ---------- Reset ---------- */ | |||
* { | * { | ||
margin: 0; | margin: 0; | ||
| 第44行: | 第45行: | ||
} | } | ||
/* ---------- Layout ---------- */ | |||
.header-container { | .header-container { | ||
width: 100%; | width: 100%; | ||
| 第62行: | 第64行: | ||
background: transparent; | background: transparent; | ||
border-radius: 4px; | border-radius: 4px; | ||
overflow: hidden; | overflow: hidden; | ||
} | } | ||
| 第96行: | 第95行: | ||
} | } | ||
/* ---------- Carousel ---------- */ | |||
.carousel { | .carousel { | ||
position: relative; | position: relative; | ||
| 第172行: | 第108行: | ||
width: 100%; | width: 100%; | ||
height: 100%; | height: 100%; | ||
transition: transform 0.5s ease; | transition: transform 0.5s ease; /* 图片切换过渡,保留 */ | ||
} | } | ||
| 第199行: | 第135行: | ||
} | } | ||
/* 箭头按钮:完全重置浏览器默认样式,避免按下时位移 */ | |||
.carousel-btn { | |||
position: absolute; | |||
top: 50%; | |||
transform: translateY(-50%); | |||
width: clamp(24px, 3.2vw, 36px); | |||
height: clamp(24px, 3.2vw, 36px); | |||
background: rgba(0, 0, 0, 0.4); | |||
color: #fff; | |||
border: none; | |||
outline: none; | |||
border-radius: 50%; | |||
font-size: clamp(12px, 1.6vw, 18px); | |||
line-height: 1; | |||
padding: 0; | |||
margin: 0; | |||
cursor: pointer; | |||
z-index: 10; | |||
display: flex; | |||
align-items: center; | |||
justify-content: center; | |||
-webkit-appearance: none; | |||
appearance: none; | |||
-webkit-tap-highlight-color: transparent; | |||
user-select: none; | |||
touch-action: manipulation; | |||
} | |||
.carousel-btn:hover, | |||
.carousel-btn:active, | |||
.carousel-btn:focus { | |||
background: rgba(0, 0, 0, 0.6); | |||
outline: none; | |||
box-shadow: none; | |||
transform: translateY(-50%); /* 强制固定,防止按下时产生位移 */ | |||
} | |||
.prev-btn { | .prev-btn { left: clamp(5px, 1vw, 12px); } | ||
.next-btn { right: clamp(5px, 1vw, 12px); } | |||
.next-btn { | |||
.carousel-indicators { | .carousel-indicators { | ||
| 第243行: | 第188行: | ||
height: 10px; | height: 10px; | ||
border-radius: 50%; | border-radius: 50%; | ||
background: rgba(255,255,255,0.5); | background: rgba(255, 255, 255, 0.5); | ||
cursor: pointer; | cursor: pointer; | ||
} | } | ||
.indicator.active { | .indicator.active { | ||
background: #fff; | background: #fff; | ||
} | } | ||
@media (max-width: | @media (max-width: 768px) { | ||
.carousel- | .carousel-indicators { bottom: 10px; } | ||
.indicator { width: 8px; height: 8px; } | |||
} | |||
} | @media (max-width: 480px) { | ||
.indicator { width: 6px; height: 6px; } | |||
} | |||
/* ---------- 响应式容器宽度 ---------- */ | |||
@media (min-width: 1025px) { | |||
.container { width: 30vw; } | |||
.side-images-container { width: 35vw; } | |||
.header-container { padding-left: calc(50vw + 40px); } | |||
} | |||
@media (min-width: 769px) and (max-width: 1024px) { | |||
.container { width: 31vw; } | |||
.side-images-container { width: 31vw; } | |||
.header-container { padding-left: calc(50vw + 30px); } | |||
} | } | ||
@media (max-width: 768px) { | @media (max-width: 768px) { | ||
.carousel- | .carousel-section { | ||
flex-direction: column; | |||
align-items: center; | |||
padding: 0; | |||
gap: 15px; | |||
} | } | ||
. | .container { | ||
width: 92vw; | |||
max-width: 310px; | |||
} | } | ||
. | .side-images-container { | ||
width: 92vw; | |||
max-width: 310px; | |||
gap: 15px; | |||
} | } | ||
. | .header-container { | ||
padding-left: 0; | |||
text-align: center; | |||
} | } | ||
} | } | ||
@media (max-width: 480px) { | @media (max-width: 480px) { | ||
. | .container { width: 94vw; min-width: 260px; } | ||
.side-images-container { width: 94vw; min-width: 260px; } | |||
. | |||
} | } | ||
/* ---------- 标题 ---------- */ | |||
.main-title { | .main-title { | ||
font-size: min(4vw, 26px); | font-size: min(4vw, 26px); | ||
| 第312行: | 第257行: | ||
.sub-title { | .sub-title { | ||
font-size: min(3vw, 18px); | font-size: min(3vw, 18px); | ||
margin | margin: 10px 0 15px; | ||
text-align: left; | text-align: left; | ||
padding: 0 10px; | padding: 0 10px; | ||
color: #666; | color: #666; | ||
| 第320行: | 第264行: | ||
@media (max-width: 768px) { | @media (max-width: 768px) { | ||
.main-title, .sub-title { | .main-title, .sub-title { text-align: center; } | ||
} | } | ||
/* | /* ---------- 图片淡入动画(保留) ---------- */ | ||
.carousel-item img, .side-image-item img { | .carousel-item img, .side-image-item img { | ||
opacity: 0; | opacity: 0; | ||
| 第374行: | 第316行: | ||
<script> | <script> | ||
(function () { | |||
const | const carousel = document.getElementById("carousel"); | ||
const | const wrapper = document.getElementById("carouselWrapper"); | ||
const indicators = document.getElementById("indicators"); | const indicators = document.getElementById("indicators"); | ||
const | const items = document.querySelectorAll(".carousel-item"); | ||
const itemCount = | const itemCount = items.length; | ||
let currentIndex = 0; | let currentIndex = 0; | ||
let autoPlay; | |||
function renderIndicators() { | function renderIndicators() { | ||
indicators.innerHTML = ""; | indicators.innerHTML = ""; | ||
for (let i = 0; i < itemCount; i++) { | for (let i = 0; i < itemCount; i++) { | ||
const | const dot = document.createElement("div"); | ||
dot.className = `indicator ${i === currentIndex ? "active" : ""}`; | |||
dot.addEventListener("click", () => goToSlide(i)); | |||
indicators.appendChild( | indicators.appendChild(dot); | ||
} | } | ||
} | } | ||
| 第394行: | 第337行: | ||
function goToSlide(index) { | function goToSlide(index) { | ||
currentIndex = index; | currentIndex = index; | ||
wrapper.style.transform = `translateX(-${currentIndex * 100}%)`; | |||
renderIndicators(); | renderIndicators(); | ||
} | |||
function nextSlide() { | |||
goToSlide((currentIndex + 1) % itemCount); | |||
} | } | ||
function prevSlide() { | function prevSlide() { | ||
goToSlide((currentIndex - 1 + itemCount) % itemCount); | |||
} | } | ||
function | function startAutoPlay() { | ||
autoPlay = setInterval(nextSlide, 5000); | |||
} | } | ||
function restartAutoPlay() { | |||
clearInterval(autoPlay); | |||
startAutoPlay(); | |||
} | |||
carousel.addEventListener("mouseenter", () => clearInterval(autoPlay)); | carousel.addEventListener("mouseenter", () => clearInterval(autoPlay)); | ||
carousel.addEventListener("mouseleave", | carousel.addEventListener("mouseleave", restartAutoPlay); | ||
let startX = 0; | let startX = 0; | ||
carousel.addEventListener("touchstart", (e) => { | carousel.addEventListener("touchstart", (e) => { | ||
startX = e.touches[0].clientX; | startX = e.touches[0].clientX; | ||
| 第426行: | 第368行: | ||
carousel.addEventListener("touchend", (e) => { | carousel.addEventListener("touchend", (e) => { | ||
const diff = startX - e.changedTouches[0].clientX; | |||
if ( | if (diff > 50) nextSlide(); | ||
else if (diff < -50) prevSlide(); | |||
restartAutoPlay(); | |||
}, { passive: true }); | }, { passive: true }); | ||
prevBtn.addEventListener("click", prevSlide); | document.getElementById("prevBtn").addEventListener("click", prevSlide); | ||
nextBtn.addEventListener("click", nextSlide); | document.getElementById("nextBtn").addEventListener("click", nextSlide); | ||
window.addEventListener("resize", () => goToSlide(currentIndex)); | |||
// 图片淡入:已缓存的立即显示,未加载完成的等待 load/error | |||
document.querySelectorAll(".carousel-item img, .side-image-item img").forEach((img) => { | |||
if (img.complete) { | |||
img.style.opacity = "1"; | |||
} else { | |||
img.addEventListener("load", () => { img.style.opacity = "1"; }); | |||
img.addEventListener("error", () => { img.style.opacity = "1"; }); | |||
} | |||
}); | }); | ||
renderIndicators(); | |||
startAutoPlay(); | |||
})(); | |||
</script> | </script> | ||
</body> | </body> | ||
| 第777行: | 第712行: | ||
[https://www.otomads.top OTOMAD Libraries]<br> | [https://www.otomads.top OTOMAD Libraries]<br> | ||
[https://sakuranomiyaaira-my.sharepoint.com/:f:/g/personal/aira_sakuranomiyaaira_onmicrosoft_com/EupwfzfUz8VNqhS_YWGToesBkfn_bfGZPeqpbrcVQMsPgA Aira软件库]<br> | [https://sakuranomiyaaira-my.sharepoint.com/:f:/g/personal/aira_sakuranomiyaaira_onmicrosoft_com/EupwfzfUz8VNqhS_YWGToesBkfn_bfGZPeqpbrcVQMsPgA Aira软件库]<br> | ||
</div> | </div> | ||
<div class="mini-block"> | <div class="mini-block"> | ||
2026年8月8日 (六) 17:23的最新版本

Create
💻 创建页面
感谢您对SOKA CAFE的编辑贡献!但也请在过程中务必依照创作协议及版权,遵循CC BY-SA 3.0协议!
准备好了?来尝试创建页面吧!

Notice
⚠️ 入站须知
Soka Cafe一直是一个合作性、公益性的网站,我们致力于营造和谐的社区环境,并热情地欢迎任何人参与我们之间的创作,不论您的信仰、外表、地域.... 为了打造一个和谐的、无骚扰的社区环境,请通读入站须知,了解网站的性质及规则。
Plan
📄 任务计划
Soka Cafe的基本底层已大体完确! 现在的最紧要的人物是登场作品分区的规范及完成度!这对创学新人入坑的帮助极其重要! 没有相关技术不要紧,请使用“可视化编辑器”来进行编辑!如果有任何技术问题请在页面下方获取我们的联系方式!
Website
🛜 友情站点
百度创价学会贴吧
创价日文Wiki
导师日文wiki
哲学中文维基
旧哲学中文维基
潮学维基
亚文化维基
中文音MAD维基
OTOMAD Libraries
Aira软件库
Contact
📞 联系我们
本站点以八叶莲华会社的名义设立,我们是中华阵营活跃的最大创价学会二创主题团体,欢迎各位对音MAD或AIR本文化感兴趣的各位加入我们团体!
八叶莲华会社QQ群聊:3681760584
八叶莲华会社QQ频道
八叶莲华会社Discord频道
前创价中文维基 群聊:1150098641
创价学会资源QQ群:256770365









