2019年5月9日 星期四

改變寬度,就會改變內容

https://codepen.io/mukiwu/pen/OPWxjg


$(document).ready(function(){
  if(matchMedia) {
    var mq = window.matchMedia( "(min-width: 500px)" );
   
    //
    mq.addListener(WidthChange);
   
    //
    WidthChange(mq);
  }
 
  function WidthChange(mq){
    if (mq.matches) {
      // window width is at least 500px
      $(".a").text("match");
    }
    else {
      // window width is less than 500px
      $(".a").text("nomatch");
    }
  }
})

---
也可以這樣寫

if (mq.matches) {
// window width is at least 768px
$("header nav ul").show(100);
}
else {
// window width is less than 768px
$("header nav ul").hide(100);

 其他rwd參考
http://slides.com/mukiwu/rwd-experience#/

沒有留言:

張貼留言

將物件置中的方法之一

大物件的css margin : auto ; display :   flex ; 小物件的css           margin : auto ; 就可以達到小物件的置中了