我在我的网页上使用了jqZoom和Bootstrap,而Bootstrap打破了jqZoom的缩放,如JqZoom and Twitter Bootstrap Conflict
中所述我还为可缩放图像应用了设置'max-width:none'的修复。这在某些情况下解决了这个问题。但是如果大图像非常大,则缩放的行为就好像只有一部分图像存在一样。它似乎无法根据图像的大小调整镜头。
我该如何解决这个问题?
您可以在以下两个链接中看到效果。它们每个显示两个图像。第一个在两种情况下都很好用。第二个只有没有Bootstrap。
Version with Bootstrap (not working)
Version without Bootstrap (working)
源代码如下所示,该部分仅出现在带有注释的 with Bootstrap 版本中:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- the following is only present in the *with Bootstrap* section -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
<!-- the following is only present in the *with Bootstrap* section -->
<link rel="stylesheet" type="text/css" href="stylesheets/jquery.jqzoom.css" >
<style>
.flowBreak
{
clear:both
}
.zoomable img {max-width:none}
</style>
</head>
<body>
<h5>Example 1</h5>
<a href='images/selfTest.png' class='zoomable'>
<img src='images/selfTest_small.png' />
</a>
<div class='flowBreak'>
</div>
<h5>Example 2</h5>
<a href='images/example2.png' class='zoomable'>
<img src='images/example2_small.png' />
</a>
<div class='flowBreak'>
</div>
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js' type='text/javascript'>
</script>
<script src='javascripts/jquery.jqzoom-core-pack.js' type='text/javascript'>
</script>
<script type='text/javascript'>
$(document).ready(function(){
$('.zoomable').jqzoom();
});
</script>
</body>
</html>
答案 0 :(得分:2)
您必须将css规则从.zoomable img {..}
更改为img {..}
,但我们不明白原因。该插件使用返回错误宽度的jquery函数。 :(
完整的工作示例如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--<link href="bootstrap.min.css" rel="stylesheet" media="screen">-->
<link href="bootstrap-experiments.css" rel="stylesheet" media="screen">
<!--<link href="bootstrap-responsive.css" rel="stylesheet">-->
<link rel="stylesheet" type="text/css" href="jquery.jqzoom.css" >
<style>
.flowBreak {
clear: both;
}
img {
max-width: none;
}
</style>
</head>
<body>
<h5>Example 1</h5>
<a href='selfTest.png' class='zoomable'>
<img src='selfTest_small.png'/>
</a>
<div class='flowBreak'>
</div>
<h5>Example 2</h5>
<a href='example2.png' class='zoomable'>
<img src='example2_small.png'/>
</a>
<div class='flowBreak'>
</div>
<script src='jquery.min.js' type='text/javascript'></script>
<!--<script src='jquery.jqzoom-core-pack.js' type='text/javascript'></script>-->
<script src='jquery.jqzoom-core.js' type='text/javascript'></script>
<script type='text/javascript'>
$(document).ready (function (){
$('.zoomable').jqzoom ();
});
</script>
</body>
</html>