轮播图板块4

This commit is contained in:
2026-09-22 16:37:46 +08:00
parent d28ba4810e
commit c915268d5b
3 changed files with 340 additions and 2 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

+220 -2
View File
@@ -367,7 +367,7 @@ img {
transform: translateX(-50%); transform: translateX(-50%);
width: 1200px; width: 1200px;
height: 105px; height: 105px;
background: rgba(255, 255, 255, 0.3); background: #FDFDFD;
box-sizing: border-box; box-sizing: border-box;
z-index: 2; z-index: 2;
display: flex; display: flex;
@@ -416,13 +416,231 @@ img {
white-space: nowrap; white-space: nowrap;
} }
/* ========== 板块4 ========== */
.block-4 {
position: absolute;
top: 614px;
left: 50%;
transform: translateX(-50%);
width: 1200px;
height: 400px;
background: #FDFDFD;
box-sizing: border-box;
z-index: 2;
}
.block-4 .block-4-logo {
position: absolute;
top: 2px;
right: 21px;
width: 64px;
height: 61px;
z-index: 3;
}
.block-4 .block-4-carousel {
position: absolute;
left: 14px;
top: 15px;
width: 616px;
height: 344px;
background: #d9d9d9;
overflow: hidden;
}
.block-4 .carousel-slide {
position: absolute;
inset: 0;
opacity: 0;
transition: opacity 0.4s ease;
}
.block-4 .carousel-slide.is-active {
opacity: 1;
z-index: 1;
}
.block-4 .carousel-slide img {
width: 100%;
height: 100%;
object-fit: cover;
background: #c5d0de;
}
.block-4 .carousel-slide:nth-child(2) img {
background: #b7c6d8;
}
.block-4 .carousel-slide:nth-child(3) img {
background: #a8bbd0;
}
.block-4 .carousel-slide p {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 40px;
margin: 0;
padding: 0 16px;
background: rgba(11, 64, 138, 0.72);
color: #fff;
font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
font-size: 16px;
font-weight: 400;
line-height: 40px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.block-4 .carousel-btn {
position: absolute;
top: 50%;
z-index: 2;
width: 28px;
height: 48px;
margin-top: -24px;
border: 0;
background: rgba(0, 0, 0, 0.35);
color: #fff;
font-size: 24px;
line-height: 48px;
cursor: pointer;
}
.block-4 .carousel-prev {
left: 0;
}
.block-4 .carousel-next {
right: 0;
}
.block-4 .carousel-dots {
position: absolute;
right: 12px;
bottom: 12px;
z-index: 2;
display: flex;
gap: 6px;
}
.block-4 .carousel-dots button {
width: 8px;
height: 8px;
padding: 0;
border: 0;
border-radius: 50%;
background: rgba(255, 255, 255, 0.55);
cursor: pointer;
}
.block-4 .carousel-dots button.is-active {
background: #fff;
}
.block-4 .block-4-tabs {
position: absolute;
left: 666px;
top: 25px;
display: flex;
gap: 8px;
}
.block-4 .block-4-tab {
width: 83px;
height: 22px;
padding: 0;
border: 0;
border-radius: 11px;
background: transparent;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
.block-4 .block-4-tab span {
width: 100%;
height: 22px;
font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
font-weight: 300;
font-size: 16px;
color: #7EA3CC;
line-height: 22px;
text-align: center;
font-style: normal;
text-transform: none;
}
.block-4 .block-4-tab.is-active {
background: #7EA3CC;
}
.block-4 .block-4-tab.is-active span {
color: #FFFFFF;
}
.block-4 .block-4-line {
position: absolute;
left: 659px;
top: 66px;
width: 523px;
height: 1px;
background: #6789B0;
}
.block-4 .block-4-panel {
display: none;
}
.block-4 .block-4-panel.is-active {
display: block;
}
.block-4 .block-4-item {
position: absolute;
left: 660px;
width: 495px;
height: 36px;
background: #D9D9D9;
display: flex;
align-items: center;
padding-left: 12px;
box-sizing: border-box;
}
.block-4 .block-4-item span {
width: 305px;
height: 16px;
font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
font-weight: 400;
font-size: 16px;
color: #414141;
line-height: 16px;
letter-spacing: 1px;
text-align: left;
font-style: normal;
text-transform: none;
white-space: nowrap;
overflow: hidden;
}
.block-4 .block-4-item:nth-child(1) { top: 73px; }
.block-4 .block-4-item:nth-child(2) { top: 123px; }
.block-4 .block-4-item:nth-child(3) { top: 173px; }
.block-4 .block-4-item:nth-child(4) { top: 223px; }
.block-4 .block-4-item:nth-child(5) { top: 273px; }
.block-4 .block-4-item:nth-child(6) { top: 323px; }
/* ========== Footer ========== */ /* ========== Footer ========== */
.footer { .footer {
position: relative; position: relative;
width: 100%; width: 100%;
height: 522px; height: 522px;
background: url("assest/网站底部1600 1.png") center top / 100% 100% no-repeat; background: url("assest/网站底部1600 1.png") center top / 100% 100% no-repeat;
margin-top: 120px; margin-top: 540px;
box-sizing: border-box; box-sizing: border-box;
} }
+120
View File
@@ -147,6 +147,62 @@
</ul> </ul>
</section> </section>
<!-- 板块4 -->
<section class="block-4">
<img class="block-4-logo" src="assest/新闻logo.png" alt="">
<div class="block-4-carousel">
<div class="carousel-slide is-active">
<img src="" alt="">
<p>海军某部开展实战化训练 锤炼制胜本领</p>
</div>
<div class="carousel-slide">
<img src="" alt="">
<p>东部战区海军某驱逐舰支队海上演训</p>
</div>
<div class="carousel-slide">
<img src="" alt="">
<p>海军航空兵某团组织跨昼夜飞行训练</p>
</div>
<button type="button" class="carousel-btn carousel-prev" aria-label="上一张"></button>
<button type="button" class="carousel-btn carousel-next" aria-label="下一张"></button>
<div class="carousel-dots">
<button type="button" class="is-active" aria-label="第1张"></button>
<button type="button" aria-label="第2张"></button>
<button type="button" aria-label="第3张"></button>
</div>
</div>
<div class="block-4-tabs">
<button type="button" class="block-4-tab is-active" data-tab="0"><span>军政要闻</span></button>
<button type="button" class="block-4-tab" data-tab="1"><span>东海要闻</span></button>
<button type="button" class="block-4-tab" data-tab="2"><span>部队要闻</span></button>
</div>
<div class="block-4-line"></div>
<div class="block-4-panel is-active" data-panel="0">
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
</div>
<div class="block-4-panel" data-panel="1">
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
</div>
<div class="block-4-panel" data-panel="2">
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
<div class="block-4-item"><span>内容文字占位内容文字占位</span></div>
</div>
</section>
<!-- 板块:Footer --> <!-- 板块:Footer -->
<footer class="footer"> <footer class="footer">
<a class="footer-link footer-link-stats" href="javascript:;">信息统计</a> <a class="footer-link footer-link-stats" href="javascript:;">信息统计</a>
@@ -264,6 +320,70 @@
</div> </div>
</div> </div>
</footer> </footer>
<script>
(function () {
var root = document.querySelector(".block-4-carousel");
if (!root) return;
var slides = root.querySelectorAll(".carousel-slide");
var dots = root.querySelectorAll(".carousel-dots button");
var index = 0;
var timer = null;
function show(next) {
index = (next + slides.length) % slides.length;
slides.forEach(function (slide, i) {
slide.classList.toggle("is-active", i === index);
});
dots.forEach(function (dot, i) {
dot.classList.toggle("is-active", i === index);
});
}
function start() {
stop();
timer = setInterval(function () {
show(index + 1);
}, 4000);
}
function stop() {
if (timer) clearInterval(timer);
}
root.querySelector(".carousel-prev").addEventListener("click", function () {
show(index - 1);
start();
});
root.querySelector(".carousel-next").addEventListener("click", function () {
show(index + 1);
start();
});
dots.forEach(function (dot, i) {
dot.addEventListener("click", function () {
show(i);
start();
});
});
root.addEventListener("mouseenter", stop);
root.addEventListener("mouseleave", start);
start();
})();
(function () {
var tabs = document.querySelectorAll(".block-4-tab");
var panels = document.querySelectorAll(".block-4-panel");
tabs.forEach(function (tab) {
tab.addEventListener("click", function () {
var index = tab.getAttribute("data-tab");
tabs.forEach(function (item) {
item.classList.toggle("is-active", item === tab);
});
panels.forEach(function (panel) {
panel.classList.toggle("is-active", panel.getAttribute("data-panel") === index);
});
});
});
})();
</script>
</body> </body>
</html> </html>