在IE中使用JQuery Sparkline的问题

时间:2009-06-22 07:32:14

标签: javascript jquery internet-explorer jquery-plugins

我在页面中使用了jQuery sparkline(http://omnipotent.net/jquery.sparkline/)。这给我在IE中的问题,如果容器DIV不够大,无法显示它,尝试使用Firefox / Chrome,它运行正常。请参阅示例代码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <script type="text/javascript" src="jquery-1.3.1.js"></script>
    <script type="text/javascript" src="jquery.sparkline.min.js"></script>
    <script type="text/javascript">
    $(function() {
        var myvalues = [10,8,5,7,4,4,1];
        $('.dynamicsparkline').sparkline(myvalues, {height:'100px',width:'300px'});
    });
    </script>
</head>
<body>
<div style="height:100px;width:400px;overflow:auto;border:1px solid black">
          Testing Header
          <br/>
          <span class="dynamicsparkline">Loading..</span>
          <br/>
          Testing Footer
</body>
</html>

有人可以帮我吗?

谢谢, 的Manoj

1 个答案:

答案 0 :(得分:2)

Gareth Watts(http://omnipotent.net/jquery.sparkline/)帮助我通过向容器div添加“position:relative”来解决这个问题。

这是代码

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <script type="text/javascript" src="jquery-1.3.1.js"></script>
    <script type="text/javascript" src="jquery.sparkline.min.js"></script>
    <script type="text/javascript">
    $(function() {
        var myvalues = [10,8,5,7,4,4,1];
        $('.dynamicsparkline').sparkline(myvalues, {height:'100px',width:'300px'});
    });
    </script>
</head>
<body>
<div style="height:100px;width:400px;overflow:auto;border:1px solid black;position: relative">
          Testing Header
          <br/>
          <span class="dynamicsparkline">Loading..</span>
          <br/>
          Testing Footer
</div>
</body>
</html>

只能在IE7中复制。

由于