Chủ Nhật, 14 tháng 9, 2014

trình diễn mọi màn hình bằng css

****bootraps viết css:
 + Dạng 1:
   <link href='mobi.css' media='screen and (max-width: 320px)' >
   <link href='mobi.css' media='screen and (min-width: 321px) and (max-width: 360px)'>
   <link href='mobi.css' media='screen and (min-width: 361px) and (max-width: 480px)'>
   <link href='mobi.css' media='screen and (min-width: 480px) and (max-width: 640px)'>
   <link href='mobi.css' media='screen and (min-width: 641px) and (max-width: 767px)'>
 + Dạng 2:
 @media screen and (max-width: 320px){  
   .main-center{
      width: 320px;
   }
 }
 @media screen and (max-width: 360px){ 
 .main-center{
      width: 360px;
   }
 }
 @media screen and (max-width: 480px){ 
 .main-center{
      width: 480px;
   }
 }
 @media screen and (max-width: 640px){ 
   .main-center{
      width: 640px;
   }
 }
****bootraps chia cột màn hình 
****bootraps ẩn mobi + ẩn desktop
-hidden-xs(ẩn mobi)
-hidden-lg(ẩn desktop) 

****Chỉ hiên code trên trình mobi hoặc desktop
1.code php
if(preg_match("/iPhone|iPad|Android|Windows Phone/is", $_SERVER['HTTP_USER_AGENT'])){
  if($_SERVER['HTTP_HOST']!=="m.bige.vn"){
    header("Loaction:http://m.bige.vn");          
  }
  print('Hiện dòng này trên Mobi');
}else{
  print('Hiện dòng này trên Desktop');
}

2.javascript
2-1.   
<script> 
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)){  
 window.location ="http://m.bige.vn/";      }
</script>

2-2.
<script> 
var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);
if (isMobile) {
  jQuery('body').removeClass('ps-static');
  jQuery('body').addClass('ps-phone');
  jQuery('.page').click(function() {
    jQuery('body').removeClass('ind');
    swipe_animate_false();
  });
};
</script>

Không có nhận xét nào:

Đăng nhận xét