5

我有一个页面

按下按钮后,你会看到 lib jquery.knob.js(circle) 的元素,我想改变圆圈大小,我写了这段代码:

<div style="float:left; width:255px; height:155px">
            <input class="knob" data-fgColor="#9dc806" data-cgColor="black" data-bgColor="#7d7d7d" data-tickColor="black" data-thickness=".25" data-readOnly=true value="<?php echo $percent; ?>">
        </div>

但是如果我改变div的宽度和高度,圆的大小不会改变吗?

pb.php的所有代码页:

<?php
header('Content-Type: text/html; charset=utf-8');
include '../connect.php';
include '../ProcessingMySQL.php';
$mysqli = new ProcessingMySQL($hostname, $user_name, $password, $db_name);
$site = $_POST['sites'];
$percent = $mysqli->getPercentTopQuery($site);
?>

<html>
    <head>
    <style type="text/css">
        .knob{color:#000000 !important;}
    </style>

        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
        <script src="js/jquery.knob.js"></script>
        <script>
            $(function() {
                $(".knob").knob();
                var val,up=0,down=0,i=0
                    ,$idir = $("div.idir")
                    ,$ival = $("div.ival")
                    ,incr = function() { i++; $idir.show().html("+").fadeOut(); $ival.html(i); }
                    ,decr = function() { i--; $idir.show().html("-").fadeOut(); $ival.html(i); };
                $("input.infinite").knob(
                                    {
                                    'min':0
                                    ,'max':20
                                    ,'stopper':false
                                    ,'change':function(v){
                                                if(val>v){
                                                    if(up){
                                                        decr();
                                                        up=0;
                                                    }else{up=1;down=0;}
                                                }else{
                                                    if(down){
                                                        incr();
                                                        down=0;
                                                    }else{down=1;up=0;}
                                                }
                                                val=v;
                                            }
                                    }
                                );     
                                $('.knob').val($('.knob').val() + '%');     
             });
        </script>
        <style>
            h2{color:#87CEEB;font-family:'Georgia';}
        </style>
    </head>
    <body>
        <h1>Процент запросов в топе для сайта <?php echo $site; ?></h1>
        <div style="float:left; width:255px; height:155px">
            <input class="knob" data-fgColor="#9dc806" data-cgColor="black" data-bgColor="#7d7d7d" data-tickColor="black" data-thickness=".25" data-readOnly=true value="<?php echo $percent; ?>">
        </div>

    </body>
</html>
4

1 回答 1

1
<div style="float:left; width:255px; height:155px">
            <input class="knob" data-fgColor="#9dc806" data-cgColor="black" data-bgColor="#7d7d7d" data-tickColor="black" data-thickness=".25" data-readOnly=true data-width="255" value="<?php echo $percent; ?>">
        </div>

尝试将data-width="width_of_circle"属性添加到您的input.knob. 据我所知,这就是控制圆宽度的方法。就像上面的代码一样(宽度设置为 255)

于 2012-12-18T09:50:04.527 回答