2015-10-06 30 views
-1

我想通過滾動縮放div和內部,我看到這個小提琴並試圖轉載它http://jsfiddle.net/SHAPE/1/,但它不工作(沒有縮放)。使用jquery縮放div

這裏我的HTML:

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<link href="zoom.css" type="text/css" rel="stylesheet" /> 
     <script type="text/javascript" src="zoom.js"></script> 
<script type="text/javascript" src="jquery/jquery.mousewheel.js"></script> 
<script type="text/javascript" src="jquery/jquery-1.8.3.min.js"></script> 
</head> 

<body> 
<h1>Zoom</h1> 
<div id="zoomContent"> 
    <p class="col1">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> 
    <p class="col2">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> 
</div> 
</body> 

我的JS:

jQuery(function($) { 
    $('#zoomContent') 
     .bind('mousewheel', function(event, delta) { 
      var _elm = $(this), 
       _increment = delta * 1.2, 
       _current = Number(_elm.css("font-size").split("px")[0]); 
      console.log(_current + _increment); 
      _elm.css("font-size", _current + _increment); 
      return false; 
     }); 
}); 

我的CSS:

#zoomContent{ 
     width: 600px; 
    height: 300px; 
    font-size: 16px; 
    overflow: scroll; 
    border: 5px solid #333; 
} 

.col1, 
.col2{ 
     width: 10em; 
    padding: 0.3em; 
    background: red; 
    float: left; 
} 

.col2{ 
     background: green; 
} 

我忘記什麼?

感謝

回答

1

您的代碼使用jQuery插件,以便他們工作的插件必須包含核心jQuery框架後

下面兩行應該是倒過來

<script type="text/javascript" src="jquery/jquery.mousewheel.js"></script> 
<script type="text/javascript" src="jquery/jquery-1.8.3.min.js"></script> 

由於他們是在撥弄你鏈接

+0

這是它。謝謝 – Laetis