<!DOCTYPE html>
<!-- saved from url=(0044)http://www.swiper.com.cn/demo/11-nested.html -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<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;
}
.swiper-container-v {
background: #eee;
}
</style>
</head>
<body>
<!-- Swiper -->
<div class="swiper-container swiper-container-h swiper-container-horizontal">
<div class="swiper-wrapper" style="transform: translate3d(-1400px, 0px, 0px); transition-duration: 0ms;">
<div class="swiper-slide swiper-slide-prev" style="width: 1350px; margin-right: 50px;">Horizontal Slide 1</div>
<div class="swiper-slide swiper-slide-active" style="width: 1350px; margin-right: 50px;">
<div class="swiper-container swiper-container-v swiper-container-vertical">
<div class="swiper-wrapper" style="transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;">
<div class="swiper-slide swiper-slide-active" style="height: 312px; margin-bottom: 50px;">Vertical Slide 1</div>
<div class="swiper-slide swiper-slide-next" style="height: 312px; margin-bottom: 50px;">Vertical Slide 2</div>
<div class="swiper-slide" style="height: 312px; margin-bottom: 50px;">Vertical Slide 3</div>
<div class="swiper-slide" style="height: 312px; margin-bottom: 50px;">Vertical Slide 4</div>
<div class="swiper-slide" style="height: 312px; margin-bottom: 50px;">Vertical Slide 5</div>
</div>
<div class="swiper-pagination swiper-pagination-v swiper-pagination-clickable swiper-pagination-bullets"><span class="swiper-pagination-bullet swiper-pagination-bullet-active"></span><span class="swiper-pagination-bullet"></span><span class="swiper-pagination-bullet"></span><span class="swiper-pagination-bullet"></span><span class="swiper-pagination-bullet"></span></div>
</div>
</div>
<div class="swiper-slide swiper-slide-next" style="width: 1350px; margin-right: 50px;">Horizontal Slide 3</div>
<div class="swiper-slide" style="width: 1350px; margin-right: 50px;">Horizontal Slide 4</div>
</div>
<!-- Add Pagination -->
<div class="swiper-pagination swiper-pagination-h swiper-pagination-clickable swiper-pagination-bullets"><span class="swiper-pagination-bullet"></span><span class="swiper-pagination-bullet swiper-pagination-bullet-active"></span><span class="swiper-pagination-bullet"></span><span class="swiper-pagination-bullet"></span></div>
</div>
<!-- Swiper JS -->
<script src="js/swiper.min.js"></script>
<!-- Initialize Swiper -->
<script>
var swiperH = new Swiper('.swiper-container-h', {
pagination: '.swiper-pagination-h',
paginationClickable: true,
mousewheelControl : true,
spaceBetween: 50
});
var swiperV = new Swiper('.swiper-container-v', {
pagination: '.swiper-pagination-v',
paginationClickable: true,
direction: 'vertical',
mousewheelControl : true,
mousewheelReleaseOnEdges : true,
spaceBetween: 50
});
</script>
</body></html>
这个问题官方已经想到了:
swiper官方api-配置选项-nested
=======================2017.09.27 12:27更新======================
抱歉,上面的代码滚轮事件是无效的,仅支持touch事件,需要对滚轮事件特殊处理: