1

単語を取得し、いくつかの関連データをdivタグにロードするajaxスクリプトがあります。

正常に動作しますが、プリローダー(jQueryなし)をdivタグに追加したいので、spin.jsを試しましたが、ページ全体でのみ動作します。これが私たちが行ったことです:(要約)

<head>
<script src="spin.min.js"></script>
</head>

<body>
 <div id="data">

 //data loads here

 </div>

<script type="text/javascript" charset="utf-8">
var opts = {
  lines: 13, // The number of lines to draw
  length: 7, // The length of each line
  width: 4, // The line thickness
  radius: 28, // The radius of the inner circle
  rotate: 0, // The rotation offset
  color: '#000', // #rgb or #rrggbb
  speed: 1, // Rounds per second
  trail: 92, // Afterglow percentage
  shadow: false, // Whether to render a shadow
  hwaccel: false, // Whether to use hardware acceleration
  className: 'spinner', // The CSS class to assign to the spinner
  zIndex: 2e9, // The z-index (defaults to 2000000000)
  top: 'auto', // Top position relative to parent in px
  left: 'auto' // Left position relative to parent in px
};
var target = document.getElementById('data');
var spinner = new Spinner(opts).spin(target);
</script>


</body>

なにが問題ですか?および他の(そしてより良い)ソリューションはありますか?

4

1 に答える 1

0

全幅data divspin.js、画像を要素の中央に垂直方向と水平方向の両方に配置するため、フルスクリーンベースでこれが表示されます。

例えば

<head>
    <script src="spin.js"></script>
</head>
<body>
    <div id="data" style="width: 100px; height: 100px; float: left;">
        <!-- Data Loads Here-->
    </div>
    <div id="NoData" style="width: 100px; height: 100px; float: left;">
        Hello Hi Bye
    </div>
    <script type="text/javascript" charset="utf-8">
        var opts = {
            lines : 13, // The number of lines to draw
            length : 7, // The length of each line
            width : 4, // The line thickness
            radius : 28, // The radius of the inner circle
            rotate : 0, // The rotation offset
            color : '#000', // #rgb or #rrggbb
            speed : 1, // Rounds per second
            trail : 92, // Afterglow percentage
            shadow : false, // Whether to render a shadow
            hwaccel : false, // Whether to use hardware acceleration
            className : 'spinner', // The CSS class to assign to the spinner
            zIndex : 2e9, // The z-index (defaults to 2000000000)
            top : 'auto', // Top position relative to parent in px
            left : 'auto' // Left position relative to parent in px
        };
        var target = document.getElementById('data');
        var spinner = new Spinner(opts).spin(target);
    </script>
</body>
于 2012-06-06T16:57:52.533 に答える