swiper插件在ie浏览器无反应,解决办法
在写pc端页面时,用swiper插件发现在ie中用不了,百度下说是swiper从3以后向手机端发展,所以在pc端无响应。后来了解到,swiper3是专门针对移动端写的。如果想兼容IE8的话,应该引入swiper2.
也就是:idangerous.swiper.js
官网演示地址:http://2.swiper.com.cn/demo/
swiper2下载地址
链接:https://pan.baidu.com/s/1rWhJ1sCbcJVf4wfBRq_MYg 密码:qcuw
参考源码:
css:
<link rel="stylesheet" type="text/css" href="../css/idangerous.swiper.css" />
js
<script src="../js/idangerous.swiper.js" type="text/javascript" charset="utf-8"></script>
html
<div class="container-middle-solution">
<div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide"> <div class="container-middle-solution-pc"> <div> <a class="title">网络解决方案</a> </div> <div>我们做响应网站,网页开发,区块链开发,UI/UX设计,CRM解决方案,托管服务器解决方案。</div> <div> <img src="../img/index-pc.png"> </div> </div> </div> <div class="swiper-slide"> <div class="container-middle-solution-pc"> <div>移动解决方案</div> <div>我们做iOS应用开发,Android应用开发,混合APP开发以及移动应用市场咨询。</div> <div> <img src="../img/index-pc.png"> </div> </div> </div> <div class="swiper-slide"> <div class="container-middle-solution-pc"> <div>网络解决方案</div> <div>我们做响应网站,网页开发,区块链开发,UI/UX设计,CRM解决方案,托管服务器解决方案。</div> <div> <img src="../img/index-pc.png"> </div> </div> </div> <div class="swiper-slide"> <div class="container-middle-solution-pc"> <div>网络解决方案</div> <div>我们做响应网站,网页开发,区块链开发,UI/UX设计,CRM解决方案,托管服务器解决方案。</div> <div> <img src="../img/index-pc.png"> </div> </div> </div> <div class="swiper-slide"> <div class="container-middle-solution-pc"> <div>网络解决方案</div> <div>我们做响应网站,网页开发,区块链开发,UI/UX设计,CRM解决方案,托管服务器解决方案。</div> <div> <img src="../img/index-pc.png"> </div> </div> </div> <div class="swiper-slide"> <div class="container-middle-solution-pc"> <div>网络解决方案</div> <div>我们做响应网站,网页开发,区块链开发,UI/UX设计,CRM解决方案,托管服务器解决方案。</div> <div> <img src="../img/index-pc.png"> </div> </div> </div> <div class="swiper-slide"> <div class="container-middle-solution-pc"> <div>网络解决方案</div> <div>我们做响应网站,网页开发,区块链开发,UI/UX设计,CRM解决方案,托管服务器解决方案。</div> <div> <img src="../img/index-pc.png"> </div> </div> </div> </div> <!-- Add Arrows --> <!--<div class="icon-left">--> <!--<div class="swiper-button-next"></div> <div class="swiper-button-prev"></div>--> <a class="arrow-left" href="#"></a> <a class="arrow-right" href="#"></a> </div> </div>
<script type="text/javascript">
var swiper = new Swiper('.swiper-container', {
// slidesPerView: "auto",
slidesPerView: 2,
spaceBetween: 0,
// mode: 'vertical', //2版本垂直滑动
// direction: 'vertical', //3版本垂直滑动
// pagination: {
// el: '.swiper-pagination',
// clickable: true,
// },
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
$('.arrow-left').on('click', function(e) {
e.preventDefault();
swiper.swipePrev();
})
$('.arrow-right').on('click', function(e) {
e.preventDefault();
swiper.swipeNext();
})
</script>
css样式问题
.swiper-container { width: 100%; padding-bottom: 100px; } /*.swiper-slide { background-position: center; background-size: cover; 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-button-prev, .swiper-container-rtl .swiper-button-next { background: url(../img/index-left.png) center center no-repeat; background-size: 100%; 100%; left: 52px; right: auto; top: 220px; width: 54px; height: 54px; } /*.arrow-left { background: url(../img/index-left.png) center center no-repeat; background-size: 100%; 100%; left: 52px; right: auto; top: 220px; width: 54px; height: 54px; }*/ .arrow-left { background: url(../img/index-left.png) no-repeat left top; position: absolute; left: 36px; top: 180px; margin-top: -15px; width: 54px; height: 54px; background-size: 100% 100%; } .arrow-right { background: url(../img/index-right.png) no-repeat left bottom; position: absolute; /* right: 10px; */ left: 110px; top: 180px; margin-top: -15px; width: 54px; height: 54px; background-size: 100% 100%; }
效果
注意:在引用css2.0是有些样式之前写的4.0的,所以样式要改,要不然起冲突
写每个轮播之间的间距,要实现除了第一个之外,其他加上margin-left。那么在<div class="swiper-slide swiper-slides"> 里面,我这加的是swiper-slides
.swiper-slides:not(:first-child){
margin-left: 10px !important;
}
作者:静默虚空
欢迎任何形式的转载,但请务必注明出处。
限于本人水平,如果文章和代码有表述不当之处,还请不吝赐教。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】