2011-12-22 10 views
3

私は現在、私はModernizr.JSにmatchmedia.jsを置き換えるならば、私の上記のコード作業が意志今MatchMedia.jsはModernizr JSに含まれていますか?

<script src="https://raw.github.com/paulirish/matchMedia.js/master/matchMedia.js"></script> 

<!-- <script> 

</script>--> 

    <script> 
     if (matchMedia('only screen and (min-width : 1025px) and (max-width : 2048px)').matches) { 
    // smartphone/iphone... maybe run some small-screen related dom scripting? 



    $(document).ready(function() { 
       var $body = $('body'); //Cache this for performance 

       var setBodyScale = function() { 
        var scaleFactor = 0.5, 
         scaleSource = $body.width(), 
         maxScale = 150, 
         minScale = 10; 

        var fontSize = scaleSource * scaleFactor; //Multiply the width of the body by the scaling factor: 

        if (fontSize > maxScale) fontSize = maxScale; 
        if (fontSize < minScale) fontSize = minScale; //Enforce the minimum and maximums 

        $('body').css('font-size', fontSize + '%'); 
       } 

       $(window).resize(function(){ 
        setBodyScale(); 
       }); 

       //Fire it when the page first loads: 
       setBodyScale(); 
      }); 
      } 
      </script> 

を使用していますか?

答えて

7

Modernizrはmqと呼ばれる類似のものを使用します。ドキュメントはhttp://www.modernizr.com/docs/#mqです。だから、modernizrを交換した後

if (Modernizr.mq('only screen and (min-width : 1025px) and (max-width : 2048px)')) { 
+0

基本的に、あなたはあなたの行を変更したいです。私は 'matchMedia'を' mq'に置き換える必要があります –

+0

そしてそれはIE9と互換ですか? –

+0

'.matches'も削除する必要がありますか? –

関連する問題