调整swiper页、header页

master
chen 2022-04-14 18:02:22 +08:00
parent 1e4a2d8939
commit aab69a8ce8
3 changed files with 262 additions and 3 deletions

96
css/datouwang.com.css Normal file
View File

@ -0,0 +1,96 @@
/* DaTouWang URL: www.datouwang.com */
body {
margin: 0;
padding: 0;
}
h2,
h4 {
font-weight: normal;
}
#persons {
position: relative;
width: 1200px;
margin: 0 auto
}
#persons .swiper-container {
padding-bottom: 60px;
}
#persons .swiper-slide {
width: 540px;
height: 340px;
}
#persons .swiper-slide .text {
position: absolute;
left: 15%;
top: 20%;
width: 90%;
margin: 0 auto;
clear: both;
overflow: hidden;
}
#persons .swiper-slide .text img {
float: left;
width: 120px;
height: 120px;
margin-right: 15px;
border: 2px solid #ededed;
}
#persons .swiper-slide h2 {
float: left;
padding-top: 0;
text-align: center;
font-size: 20px;
margin-bottom: 10px;
}
#persons .swiper-slide h4 {
float: left;
margin: 0;
width: 60%;
font-size: 16px;
}
#persons .swiper-pagination {
width: 100%;
bottom: 20px;
}
#persons .swiper-pagination-bullets .swiper-pagination-bullet {
margin: 0 5px;
border: 3px solid #fff;
background-color: #d5d5d5;
width: 10px;
height: 10px;
opacity: 1;
}
#persons .swiper-pagination-bullets .swiper-pagination-bullet-active {
border: 3px solid #00aadc;
background-color: #fff;
}
#persons .swiper-button-prev {
left: -30px;
top: 40%;
width: 45px;
height: 45px;
}
#persons .swiper-button-prev:hover {
background-position: 0 -46px;
background-size: 100%
}
#persons .swiper-button-next {
right: -30px;
top: 40%;
width: 45px;
height: 45px;
}

View File

@ -1,9 +1,81 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<title>Swiper demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<!-- Link Swiper's CSS -->
<link rel="stylesheet" href="../../css/swiper.min.css">
<!-- Demo styles -->
<style>
html,
body {
position: relative;
height: 100%;
}
body {
background: #eee;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 14px;
color: #000;
margin: 0;
padding: 0;
}
.swiper-container {
width: 100%;
height: 100%;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #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;
}
</style>
</head>
<body>
<body style="height: 2000px;">
<!-- Swiper -->
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
<div class="swiper-slide">Slide 4</div>
<div class="swiper-slide">Slide 5</div>
<div class="swiper-slide">Slide 6</div>
<div class="swiper-slide">Slide 7</div>
<div class="swiper-slide">Slide 8</div>
<div class="swiper-slide">Slide 9</div>
<div class="swiper-slide">Slide 10</div>
</div>
</div>
<!-- Swiper JS -->
<script src="../../js/swiper.min.js"></script>
<!-- Initialize Swiper -->
<script>
var swiper = new Swiper('.swiper-container', {
slidesPerView: 4,
spaceBetween: 30,
slidesPerGroup: 4,
loop: true,
loopFillGroupWithBlank: true,
});
</script>
</body>
</html>

91
pages/swiper/swiper.html Normal file
View File

@ -0,0 +1,91 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>swiper卡片叠加点击切换代码演示_大头网</title>
<link rel="stylesheet" href="../../css/swiper.min.css">
<link rel="stylesheet" href="../../css/datouwang.com.css">
<script></script>
</head>
<body>
<div id="persons">
<div class="swiper-container swiper-container-initialized swiper-container-horizontal">
<div class="swiper-wrapper">
<div class="swiper-slide swiper-slide-duplicate" data-swiper-slide-index="0">
<img src="../../imgs/public/小桶龙.png" alt="">
</div>
<div class="swiper-slide swiper-slide-duplicate" data-swiper-slide-index="1">
<img src="../../imgs/public/小桶龙.png" alt="">
</div>
<div class="swiper-slide swiper-slide-duplicate swiper-slide-duplicate-prev"
data-swiper-slide-index="2">
<img src="../../imgs/public/小桶龙.png" alt="">
</div>
<div class="swiper-slide swiper-slide-duplicate swiper-slide-duplicate-active"
data-swiper-slide-index="3">
<img src="../../imgs/public/小桶龙.png" alt="">
</div>
<div class="swiper-slide swiper-slide-duplicate-next" data-swiper-slide-index="0">
<img src="../../imgs/public/小桶龙.png" alt="">
</div>
<div class="swiper-slide swiper-slide-duplicate-next" data-swiper-slide-index="0">
<img src="../../imgs/public/小桶龙.png" alt="">
</div>
</div>
<span class="swiper-notification" aria-live="assertive" aria-atomic="true"></span>
</div>
<div class="swiper-pagination swiper-pagination-bullets"><span class="swiper-pagination-bullet"></span><span
class="swiper-pagination-bullet"></span><span class="swiper-pagination-bullet"></span><span
class="swiper-pagination-bullet swiper-pagination-bullet-active"></span></div>
<div class="swiper-button-prev" tabindex="0" role="button" aria-label="Previous slide"></div>
<div class="swiper-button-next" tabindex="0" role="button" aria-label="Next slide"></div>
</div>
<script src="../../js/swiper.min.js"></script>
<script>
var personsSwiper = new Swiper('#persons .swiper-container', {
watchSlidesProgress: true,
slidesPerView: 'auto',
centeredSlides: true,
loop: true,
autoplay: true,
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
pagination: {
el: '.swiper-pagination',
},
on: {
progress: function(progress) {
for (i = 0; i < this.slides.length; i++) {
var slide = this.slides.eq(i);
var slideProgress = this.slides[i].progress;
modify = 1;
if (Math.abs(slideProgress) > 1) {
modify = (Math.abs(slideProgress) - 1) * 0.3 + 1;
}
translate = slideProgress * modify * 260 + 'px';
scale = 1 - Math.abs(slideProgress) / 5;
zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
slide.transform('translateX(' + translate + ') scale(' + scale + ')');
slide.css('zIndex', zIndex);
slide.css('opacity', 1);
if (Math.abs(slideProgress) > 3) {
slide.css('opacity', 0);
}
}
},
setTransition: function(transition) {
for (var i = 0; i < this.slides.length; i++) {
var slide = this.slides.eq(i)
slide.transition(transition);
}
}
}
})
</script>
</body>
</html>