Tạo Slide đẹp mắt

Link https://www.pacific.net.vn/

Amhjslide
CÁCH TẠO NHƯ SAU 

Đặt tên Clas là slide-item slide-1

JAVASCRIP:: Dùng foxxtool cho vào footer

<script>
const slider = document.querySelector(‘.slide-holder’);
function activate(e) {
const items = document.querySelectorAll(‘.slide-item’);
e.target.matches(‘.custom-next’) && slider.append(items[0])
e.target.matches(‘.custom-prev’) && slider.prepend(items[items.length-1]);
}
document.addEventListener(‘click’,activate,false);
</script>

________________

file HTML 

 

<p>

<br />
<br />
</p>
<h2>Hello world</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
<p>
<br />
</p>
<h2>Hello world</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
<p> Click me! </p>
<p>
<br />
</p>
<h2>Hello world</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
<p> Click me! </p>
<p>
<br />
</p>
<h2>Hello world</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
<p> Click me! </p>
<p>
<br />
</p>
<h2>Hello world</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
<p> Click me! </p>
<p>
<br />
</p>
<h2>Hello world</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
<p> Click me! </p>
<p>
<br />
<br />
</p>
<nav class=’custom-nav’>
<i class=’icon-angle-left btn custom-prev’ name=”arrow-back-outline”></i><br />
<i class=’icon-angle-right btn custom-next’ name=”arrow-forward-outline”></i><br />
</nav>
<p><br />
</p>

__________________

custom css

/** Custom Slider **/
.slide-1 {
background: url(https://picsum.photos/id/11/2500/1667.jpg) no-repeat;
background-position: 50% 50%;
/* Can change the position to focus on part of image */
}
.slide-2 {
background: url(https://picsum.photos/id/10/2500/1667.jpg) no-repeat;
background-position: 50% 50%;
}
.slide-3 {
background: url(https://picsum.photos/id/15/2500/1667.jpg) no-repeat;
background-position: 50% 50%;
}
.slide-4 {
background: url(https://picsum.photos/id/33/5000/3333.jpg) no-repeat;
background-position: 50% 50%;
}
.slide-5 {
background: url(https://picsum.photos/id/43/1280/831.jpg) no-repeat;
background-position: 50% 50%;
}
.slide-6 {
background: url(https://picsum.photos/id/57/2448/3264.jpg) no-repeat;
background-position: 50% 50%;
}
.slide-container .section-content {
width: 100vw;
height: 83vh;
/* Change according to your desired height. NOTE: This may affect responsive styling; change tablet/mobile styling accordingly */
}
.slide-item {
width: 200px;
height: 300px;
max-width: unset;
position: absolute;
top: 50%;
transform: translateY(-50%);
z-index: 1;
background-size: cover;
border-radius: 20px;
box-shadow: 0 20px 30px rgba(255, 255, 255, 0.3) inset;
transition: transform 0.1s, left 0.75s, top 0.75s, width 0.75s, height 0.75s;
&:nth-child(1),
&:nth-child(2) {
left: 0;
top: 0;
width: 100%;
height: 100%;
transform: none;
border-radius: 0;
box-shadow: none;
opacity: 1;
}
&:nth-child(3) {
left: 50%;
}
&:nth-child(4) {
left: calc(50% + 220px);
}
&:nth-child(5) {
left: calc(50% + 440px);
}
&:nth-child(6) {
left: calc(50% + 660px);
opacity: 0;
}
}
.slide-item .col-inner {
width: min(30vw, 400px);
position: absolute;
top: 50%;
left: 3rem;
transform: translateY(-50%);
text-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
opacity: 0;
display: none;
}
.slide-item:nth-of-type(2) .col-inner {
display: block;
animation: show 0.75s ease-in-out 0.3s forwards;
}
@keyframes show {
0% {
filter: blur(5px);
transform: translateY(calc(-50% + 75px));
}
100% {
opacity: 1;
filter: blur(0);
}
}
.custom-nav {
display: flex;
position: absolute;
bottom: 2rem;
left: 50%;
transform: translateX(-50%);
z-index: 5;
user-select: none;
& .btn {
background-color: rgba(0, 0, 0, 0.1);
color: var(–fs-color-secondary);
/* Can change for any color code or primary variable */
border: 2px solid var(–fs-color-secondary);
margin: 0 0.25rem;
padding: 20%;
display: flex;
justify-content: center;
align-items: center;
width: 50px;
height: 50px;
border-radius: 50%;
cursor: pointer;
&:hover {
background-color: var(–fs-color-secondary);
color: #fff;
}
}
}


custuim table 

.slide-item {
width: 160px;
height: 125px;
top: 60%;
transform: translateY(0%);
&:nth-child(3) {
left: 50%;
}
&:nth-child(4) {
left: calc(50% + 170px);
}
&:nth-child(5) {
left: calc(50% + 340px);
}
&:nth-child(6) {
left: calc(50% + 510px);
opacity: 0;
}
}
.slide-item .col-inner {
top: 49%;
width: min(45vw, 400px);
}


MOBILE

.slide-item {
width: 100px;
height: 80px;
top: unset;
bottom: 15%;
&:nth-child(3) {
left: 50%;
}
&:nth-child(4) {
left: calc(50% + 110px);
}
&:nth-child(5) {
left: calc(50% + 250px);
}
&:nth-child(6) {
left: calc(50% + 390px);
opacity: 0;
}
}
.slide-item .col-inner {
left: 1rem;
width: min(80vw, 300px);
}
.custom-nav {
bottom: 0.5rem;
}

Mục nhập này đã được đăng trong Blog. Đánh dấu trang permalink.

Để lại một bình luận

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *