码迷,mamicode.com
首页 > 其他好文 > 详细

自适应屏幕

时间:2014-09-28 12:54:32      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   os   ar   sp   div   art   

 1 <div id="center1" class="cen_container">
 2   <div class="center1_bg">
 3     <img src="../css/images/index.jpg">
 4   </div>
 5   <div class="center1-content">
 6     <div class="dataBlock"></div>
 7     <div class="searchBlock"></div>
 8     <div class="callBlock"></div>
 9    </div>
10 </div>
1 #center1{ width:100%;min-height:634px !important;position: relative; margin:0 auto;position: relative;}
2 .center1_bg{width: 100%;height: 100%;background: url("../images/index_1.jpg") center center no-repeat;position: absolute;top: 0;left: 0;z-index: -1;}
3 .center1_bg img{width: 100%;height:auto;min-width: 1350px;}
4 .center1-content{width: 990px;height: 100%;margin: 0 auto;position: relative;}
 1 var change_c1 = function(){
 2   var w_height = $(window).height();
 3   var img_r = 1920 /1080;
 4   var window_r = $(window).width() / $(window).height();
 5   if(window_r >= img_r){
 6     $(".center1_bg img").css({
 7       ‘width‘ : ‘100%‘,
 8       ‘height‘ : ‘auto‘
 9     });
10   }else{
11     $(".center1_bg img").css({
12       ‘width‘ : ‘auto‘,
13       ‘height‘ : ‘100%‘
14     });
15   }
16   var cen1_height = (w_height - 80 + 37) >= 600 ? (w_height - 80 + 37) : 600;
17   $(‘#center1,.center1_bg‘).height(cen1_height + ‘px‘);
18   var resizeTimer = null;
19   $(window).on(‘resize‘, function () {
20       if (resizeTimer) {
21         clearTimeout(resizeTimer)
22       }
23       resizeTimer = setTimeout(function(){change_c1();}, 200);
24     }
25   );
26 }

 

自适应屏幕

标签:style   blog   color   io   os   ar   sp   div   art   

原文地址:http://www.cnblogs.com/jymz/p/3997917.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!