简体   繁体   English

当我的窗口宽度小于800px时,如何将js滑块效果更改为淡入淡出?

[英]how do i change the js slider effect to fade when my window width is less than 800px?

I'm looking for a way so that my js slider will change it's effect from (normal as it is now) to fade when my browser window is less than 800px. 我正在寻找一种方法,以便当我的浏览器窗口小于800px时,我的js滑块将其效果从(现在正常)更改为淡入淡出。 Can anybody help? 有人可以帮忙吗?

     <ul class="slider">

      <li><img src="images/1" alt="img" width="979" height="470"></li>
      <li><img src="images/2" alt="img" width="979" height="470"></li>
      <li><img src="images/3" alt="img" width="979" height="470"></li>

    </ul>

        $('.slider').bxSlider({
    navigation : true, 
        slideSpeed : 300,
        paginationSpeed : 400,  
        singleItem:true,

    });

You could roll your own script to listen for resize events and then detect if the window is less than 800 pixels wide, but I would personally check out enquire.js for this particular problem. 您可以滚动自己的脚本来侦听调整大小事件,然后检测窗口是否小于800像素宽,但是我会亲自检查一下enquire.js中的特定问题。 Using enquire.js your solution can be as easy as. 使用enquire.js,您的解决方案就很容易。

enquire.register("screen and (max-width:800px)", {

// OPTIONAL
// If supplied, triggered when a media query matches.
match : function() {

   //Code goes in here to change your slider to fade

},      

// OPTIONAL
// If supplied, triggered when the media query transitions 
// *from a matched state to an unmatched state*.
unmatch : function() {}

    //Code goes in here to set your slider transition type to normal

});

Hope that helps. 希望能有所帮助。 Enquire has been an awesome tool for me! 查询对我来说是一个了不起的工具!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果窗口宽度在800px至799px之间,则执行JS函数 - Do JS function if window width between 800px and 799px 如果窗口宽度大于800px时刷新站点,则jQuery click事件不起作用 - jQuery click event doesn't work if I refresh site when window width is bigger than 800px JS-窗口的宽度从高于800px的像素数量减少到800px以下导致触发动作 - JS - Window's width being decreased below 800px from an amount of pixels that are higher than 800px causes an action to trigger 当浏览器的尺寸小于800px时如何隐藏div - How to hide div when browser resizes to less than 800px justifiedGallery:屏幕 &lt;800px 时尝试更改图像路径 - justifiedGallery : Trying to change image path when screen <800px 我想移动左导航栏菜单 <div> 屏幕尺寸为800px时返回顶部 - I want to move my Left nav bar menu <div> to Top when the screen size is 800px Javascript-如果窗口宽度&lt;= 800px,则将活动链接移至导航顶部 - Javascript - Move active link to top of navigation if window-width <= 800px 仅当最小宽度为800px时才执行Javascript - Executing Javascript only if min-width is 800px 原型:滚动页面800px时显示元素 - prototype: show a element when scroll page pased 800px JS或jQuery或窗口调整大小或窗口宽度小于npx - JS or jQuery or window resize or when window width is less than npx
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM