`我试图建立一个静态的HTML CSS网站,并试图通过js添加滑块功能。请告知如何接近
layout
我试着按照教程,他们要么不兼容我的布局或使用Swiper JS。
我尝试了swiper js,但很难设计它的组件,尤其是位置、颜色和其他东西。
<section class="section-customers wrapper">
<div class="container caraseoul">
<div class="slide">
<img
src="./images/customers/ryan-hoffman.jpg"
alt="alexander"
class="customer-img"
/>
<blockquote class="testimonial">
<p class="testimonial-text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Ratione
excepturi sint sequi laborum, nostru,excepturi sint sequi
laborum, nostru,excepturi sint sequi laborum, nostru
</p>
<p class="testimonial-author">Ryan Hoffman</p>
<p class="testimonial-status">
<span>30 </span>kgs lost in 7 months
</p>
</blockquote>
</div>
<div class="slide">
<img
src="./images/customers/alexander.jpg"
alt="alexander"
class="customer-img"
/>
<blockquote class="testimonial">
<p class="testimonial-text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Ratione
excepturi sint sequi laborum, nostru,excepturi sint sequi
laborum, nostru,excepturi sint sequi laborum, nostru
</p>
<p class="testimonial-author">Alexander Hamilton</p>
<p class="testimonial-status">
<span>10 </span>kgs lost in 2 months
</p>
</blockquote>
</div>
<div class="slide">
<img
src="./images/customers/edward.jpg"
alt="alexander"
class="customer-img"
/>
<blockquote class="testimonial">
<p class="testimonial-text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Ratione
excepturi sint sequi laborum, nostru,excepturi sint sequi
laborum, nostru,excepturi sint sequi laborum, nostru
</p>
<p class="testimonial-author">Cristina Niosi</p>
<p class="testimonial-status">
<span>23 </span>kgs lost in 6 months
</p>
</blockquote>
</div>
<div class="slide">
<img
src="./images/customers/edward.jpg"
alt="alexander"
class="customer-img"
/>
<blockquote class="testimonial">
<p class="testimonial-text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Ratione
excepturi sint sequi laborum, nostru,excepturi sint sequi
laborum, nostru,excepturi sint sequi laborum, nostru
</p>
<p class="testimonial-author">Cristina Niosi</p>
<p class="testimonial-status">
<span>23 </span>kgs lost in 6 months
</p>
</blockquote>
</div>
<div class="slide">
<img
src="./images/customers/edward.jpg"
alt="alexander"
class="customer-img"
/>
<blockquote class="testimonial">
<p class="testimonial-text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Ratione
excepturi sint sequi laborum, nostru,excepturi sint sequi
laborum, nostru,excepturi sint sequi laborum, nostru
</p>
<p class="testimonial-author">Cristina Niosi</p>
<p class="testimonial-status">
<span>23 </span>kgs lost in 6 months
</p>
</blockquote>
</div>
<div class="slide">
<img
src="./images/customers/edward.jpg"
alt="alexander"
class="customer-img"
/>
<blockquote class="testimonial">
<p class="testimonial-text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Ratione
excepturi sint sequi laborum, nostru,excepturi sint sequi
laborum, nostru,excepturi sint sequi laborum, nostru
</p>
<p class="testimonial-author">Cristina Niosi</p>
<p class="testimonial-status">
<span>23 </span>kgs lost in 6 months
</p>
</blockquote>
</div>
<div class="slide">
<img
src="./images/customers/edward.jpg"
alt="alexander"
class="customer-img"
/>
<blockquote class="testimonial">
<p class="testimonial-text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Ratione
excepturi sint sequi laborum, nostru,excepturi sint sequi
laborum, nostru,excepturi sint sequi laborum, nostru
</p>
<p class="testimonial-author">Cristina Niosi</p>
<p class="testimonial-status">
<span>23 </span>kgs lost in 6 months
</p>
</blockquote>
</div>
<button class="slider-btn slider-btn-right">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="btn-icon"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M8.25 4.5l7.5 7.5-7.5 7.5"
/>
</svg>
</button>
<button class="slider-btn slider-btn-left">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="btn-icon"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M15.75 19.5L8.25 12l7.5-7.5"
/>
</svg>
</button>
</div>
</section>```
/* TESTIMONIAL SECTION CSS*/
.section-customers {
padding: 9.6rem 0;
background-color: #fed2d2;
}
.customer-img {
max-width: 100%;
height: 10rem;
width: 10rem;
border-radius: 50%;
box-shadow: rgba(6, 24, 44, 0.4) 0px 0px 0px 2px,
rgba(6, 24, 44, 0.65) 0px 4px 6px -1px,
rgba(255, 255, 255, 0.08) 0px 1px 0px inset;
}
.caraseoul {
display: flex;
gap: 4.8rem;
position: relative;
}
.testimonial {
color: black;
}
.slide {
display: flex;
flex-direction: column;
gap: 1.4rem;
align-items: center;
justify-content: center;
text-align: center;
padding: 5rem 0;
background-color: white;
border-radius: 6px;
box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
}
.testimonial-text {
font-size: 1.2rem;
margin: 2rem;
margin-top: auto;
}
.testimonial-author {
font-size: 2rem;
font-weight: 400;
margin-bottom: 0.6rem;
color: navy;
}
.testimonial-status {
font-size: 1.8rem;
}
.testimonial-status span {
color: #a12222;
font-weight: 600;
}
.slider-btn {
position: absolute;
background-color: white;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
padding: 0.8rem;
border: none;
}
.btn-icon {
height: 2.4rem;
width: 2.4rem;
stroke: #a12222;
}
.slider-btn-left {
left: -5%;
top: 50%;
transform: translate(0, -50%);
}
.slider-btn-right {
right: -10%;
top: 50%;
transform: translate(0, -50%);
}
`
1条答案
按热度按时间h7appiyu1#
你好第九师的队长,
你不需要任何东西,你需要使用的是SLICK-SLIDER。这是最好的和容易的图书馆,使滑块/转盘与更少的时间。在解决方案中,我只是使用CDN集成了Slick Slider,并尝试制作您想要的东西。
如果你使用slick-slider,那么你需要添加以下文件:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.min.css" integrity="sha512-17EgCFERpgZKcm0j0fEq1YCJuyAWdz9KUtv1EjVuaOz8pDnh/0nZxmU6BBXwaaxqoi9PQXnRWqlcDB027hgv9A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
在slick之前添加jQuery。js
然后你必须添加以下脚本来用途:
如果你想了解更多关于Slick滑块然后点击下面的链接:https://kenwheeler.github.io/slick/
请参考此链接的现场演示,以了解详细信息。https://jsfiddle.net/qn6urw0o/8/