醉近在做一个项目,要做一个响应式的网站的时候。
使用了SWIPERR插件来做图片左右滚动的图片,在PC端上显示一行四个。
但是切换到手机的时候,发现显示还是四个。非常别扭。图片变得很窄。
我们先来看一下原始代码:
<div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide" style="background: url(1.jpg) center;"></div> <div class="swiper-slide" style="background: url(1.jpg) center;"></div> <div class="swiper-slide" style="background: url(1.jpg) center;"></div> <div class="swiper-slide" style="background: url(1.jpg) center;"></div> <div class="swiper-slide" style="background: url(1.jpg) center;"></div> <div class="swiper-slide" style="background: url(1.jpg) center;"></div> <div class="swiper-slide" style="background: url(1.jpg) center;"></div> <div class="swiper-slide" style="background: url(1.jpg) center;"></div> <div class="swiper-slide" style="background: url(1.jpg) center;"></div> <div class="swiper-slide" style="background: url(1.jpg) center;"></div> </div> <div class="swiper-button-next"></div> <div class="swiper-button-prev"></div> <!-- Initialize Swiper --> <script>
js部分:
<script> var swiper = new Swiper('.swiper-container', { autoplay:true, autoplay: { delay: 2000, disableOnInteraction: false, }, slidesPerView: 4, spaceBetween: 8, slidesPerGroup: 1, loop: true, loopFillGroupWithBlank: true, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, }); </script>
这是官方的标准代码。基本上就是这样了。但是出现以上冲突如何解决呢?
我想到的方案是PC端一段代码,手机端一段代码,在PC端上将手机部分隐藏,在手机上将PC端隐藏。分别给它不同的属性。醉后玩美解决了SWIPER在同一页面下使用多个不同的DEMO引起的冲突样式问题。
<div class="pc"> <div class="swiper-container "> <div class="swiper-wrapper"> {pboot:list scode=21 num=10} <div class="swiper-slide" style="background: url([list:ico]) center;"></div> {/pboot:list} </div> <div class="swiper-button-next"></div> <div class="swiper-button-prev"></div> <!-- Initialize Swiper --> </div> </div> <script> var swiper = new Swiper('.pc .swiper-container', { autoplay:true, autoplay: { delay: 2000, disableOnInteraction: false, }, slidesPerView: 4, spaceBetween: 8, slidesPerGroup: 1, loop: true, loopFillGroupWithBlank: true, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, }); </script> <div class="wap"> <div class="swiper-container"> <div class="swiper-wrapper"> {pboot:list scode=21 num=10} <div class="swiper-slide" style="background: url([list:ico]) center;"></div> {/pboot:list} </div> <div class="swiper-button-next"></div> <div class="swiper-button-prev"></div> <!-- Initialize Swiper --> <script> var swiper = new Swiper('.wap .swiper-container', { autoplay:true, autoplay: { delay: 2000, disableOnInteraction: false, }, slidesPerView: 1, spaceBetween: 1, slidesPerGroup: 1, loop: true, loopFillGroupWithBlank: true, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, }); </script> </div> </div>
前海网站外包公司为了良好的用户体验,应注意并注意颜色的使用。在设计时,应通过充分结合文化,行业类型并...
松岗营销型网站建设哪个公司好站安全问题不容忽视。站。每次,遭受数百万至数十亿美元的严重损失,站都被关...
松岗网页设计价格对搜索引擎来讲友好度高,在页面中要将标题标签标注,现在很多设计人员对标签的重视度不够...
西乡手机网站建设哪个好要突出主题,突出主题涉及到很多具体的方面,比如颜色的搭面字体大小的设定方面,还...