我有这样的问题。在网站的主页上,有一个存根滑块。您需要确保特定幻灯片上的颜色.logo和按钮.menu变为黑色。
代码笔: https ://codepen.io/realHikkan/pen/LYRemqO
var swiper = new Swiper(".swiper-container", {
direction: "vertical",
slidesPerView: 1,
spaceBetween: 30,
autoplay: {
delay: 3500,
disableOnInteraction: false
},
mousewheel: true,
pagination: {
el: ".swiper-pagination",
clickable: true
}
});
@import url("https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap");
body {
font-family: 'Lato', sans-serif;
margin: 0;
}
button {
outline: none;
border: none;
cursor: pointer;
}
input {
outline: none;
}
input::placeholder {
opacity: 80%;
color: #fff;
}
.swiper-container {
position: absolute;
width: 100%;
height: 100%;
margin-left: auto;
margin-right: auto;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #000;
color: #fff;
/* Center slide text vertically */
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
.swiper-pagination {
position: absolute;
left: 65.4px;
}
.swiper-pagination-bullet {
background-color: #f5f5f5 !important;
width: 12px;
height: 12px;
opacity: 1 !important;
}
.swiper-pagination-bullet-active {
background-color: #2b2b2b !important;
}
.swiper-container-vertical>.swiper-pagination-bullets .swiper-pagination-bullet {
margin: 16px 0;
display: block;
}
.nav {
position: fixed;
width: 87.5%;
height: 36px;
margin-top: 40px;
display: flex;
align-items: center;
z-index: 9999;
}
.menu {
width: 36px;
height: 36px;
margin-left: 65.4px;
background-image: url(https://www.neir-studio.ru/img/menu_hamburger-white.svg);
background-repeat: no-repeat;
background-position: center center;
background-color: transparent;
}
.logo {
margin-left: 64px;
}
.search {
margin-left: auto;
background: transparent;
padding-bottom: 8px;
width: 400px;
border: none;
border-bottom: 1px solid #fff;
font-family: "Lato", sans-serif;
font-size: 16px;
color: #fff;
}
.main-1 {
position: relative;
color: #ffffff;
min-height: 100vh;
background-image: url(../img/1.png);
background-repeat: no-repeat;
background-position: center 50%;
background-color: #000;
background-size: cover;
}
.main-4 {
position: relative;
color: #000;
min-height: 100vh;
background-color: #fff;
background-size: auto;
}
.main-5 {
position: relative;
color: #ffffff;
min-height: 100vh;
background-image: url(../img/4.png);
background-repeat: no-repeat;
background-position: top center;
background-color: #000;
background-size: auto;
}
.cart-btn {
position: fixed;
right: 0;
width: 120px;
height: 100%;
color: #fff;
text-transform: uppercase;
font-family: "Lato", sans-serif;
background: rgba(34, 34, 34, 0.92);
backdrop-filter: blur(36px);
z-index: 9999;
}
<nav>
<div class="nav">
<button type="button" class="menu"></button>
<a href="#"><img src="https://www.neir-studio.ru/img/logo-white.svg" alt="Saint Patron" class="logo"></a>
<input type="search" name="" value="" class="search" placeholder="Search">
</div>
</nav>
<a href="#"><button type="button" class="cart-btn">Cart (0)</button></a>
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide main-1">Слайд 1</div>
<div class="swiper-slide main-4">Слайд 2</div>
<div class="swiper-slide main-5">Слайд 3</div>
</div>
<div class="swiper-pagination"></div>
</div>
<script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
我没有不同颜色的菜单图片,自行类推。
我建议您通过将幻灯片索引的按钮和徽标的类更改处理程序添加到函数来使用对幻灯片更改事件的订阅: