Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery/CSS:CSS在第一次运行脚本后消失_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript jQuery/CSS:CSS在第一次运行脚本后消失

Javascript jQuery/CSS:CSS在第一次运行脚本后消失,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我有一个倒计时到0的脚本,然后重新启动-每次都替换一个图像 问题是,计时器第一次完成后,它会再次启动,但“:”两组数字之间的样式css松动,变小变黑(并在过程中移动了一些东西),我不确定这个问题来自何处,但如果有人能看看我的代码,看看如何解决这个问题,我会很高兴的 之前: 之后: 代码: <div id="counter_2" class="counter"> <script src="http://ajax.googleapis.com/ajax/libs/jqu

我有一个倒计时到0的脚本,然后重新启动-每次都替换一个图像

问题是,计时器第一次完成后,它会再次启动,但“:”两组数字之间的样式css松动,变小变黑(并在过程中移动了一些东西),我不确定这个问题来自何处,但如果有人能看看我的代码,看看如何解决这个问题,我会很高兴的

之前:

之后:

代码:

<div id="counter_2" class="counter">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript" charset="UTF-8"></script>
    <script src="js/jquery.countdown.js" type="text/javascript" charset="UTF-8"></script>
    <script type="text/javascript">

        <!-- Replace image start -->
        <!-- The ready() function will force the browser to run wait running the javascript until the entire page has loaded -->
        $(document).ready(function() {

            // The jquery code for constructing and starting the counter
            // has been wrapped inside a function so we can call it whenever we want to
            function startCounter(imageLoader){
                $('#counter_2').countdown({
                     image: 'img/digits.png',
                     startTime: '00:10',
                     timerEnd: function(){ callback(imageLoader) },
                     format: 'mm:ss'
                })
                //Loads a new image right when the page loads
                $('#image').attr('src', imageLoader.nextImage())
            }

            // Takes care of whatever need to be done everytime
            function callback(imageLoader){
                // Replace image
                $('#image').attr('src', imageLoader.nextImage());

                // Clear the finished counter, so a new can be constructed in its place
                $('#counter_2').empty();

                // Construct a new counter and starts it
                startCounter(imageLoader);
            }

            function ImageLoader(images) {
                this.images = images;
                this.usedIndexes = {};
                this.displayedCount = 0;
            }

            ImageLoader.prototype.nextImage = function () {
                var self = this,
                    len = self.images.length,
                    usedIndexes = self.usedIndexes,
                    lastBatchIndex = self.lastBatchIndex,
                    denyLastBatchIndex = self.displayedCount !== len - 1,
                    index;

                if (this.displayedCount === len) {
                    lastBatchIndex = self.lastBatchIndex = self.lastIndex;
                    usedIndexes = self.usedIndexes = {};
                    self.displayedCount = 0;
                }

                do {
                    index = Math.floor(Math.random() * len);
                } while (usedIndexes[index] || (lastBatchIndex === index && denyLastBatchIndex));

                self.displayedCount++;
                usedIndexes[self.lastIndex = index] = true;
                return self.images[index];
            };

            // Fill in images in this array
            imageLoader = new ImageLoader(['img/wallpapers/2.jpg', 'img/wallpapers/3.jpg', 'img/wallpapers/4.jpg',
                'img/wallpapers/5.jpg', 'img/wallpapers/6.jpg', 'img/wallpapers/7.jpg', 'img/wallpapers/9.jpg',
                'img/wallpapers/10.jpg', 'img/wallpapers/11.jpg', 'img/wallpapers/12.jpg', 'img/wallpapers/13.jpg',
                'img/wallpapers/14.jpg',  'img/wallpapers/15.jpg', 'img/wallpapers/16.jpg', 'img/wallpapers/17.jpg',
                'img/wallpapers/18.jpg', 'img/wallpapers/19.jpg', 'img/wallpapers/20.jpg', 'img/wallpapers/21.jpg',
                'img/wallpapers/22.jpg', 'img/wallpapers/23.jpg', 'img/wallpapers/24.jpg', 'img/wallpapers/25.jpg',
                'img/wallpapers/26.jpg', 'img/wallpapers/27.jpg', 'img/wallpapers/28.jpg', 'img/wallpapers/29.jpg',
                'img/wallpapers/30.jpg', 'img/wallpapers/31.jpg', 'img/wallpapers/32.jpg', 'img/wallpapers/33.jpg',
                'img/wallpapers/34.jpg', 'img/wallpapers/35.jpg', 'img/wallpapers/36.jpg', 'img/wallpapers/37.jpg',
                'img/wallpapers/38.jpg', 'img/wallpapers/39.jpg', 'img/wallpapers/40.jpg', 'img/wallpapers/41.jpg']);

            // Set everything off! (Construct a new counter and starts it)
            startCounter(imageLoader);
        });

    </script>
    <style type="text/css">
        div.counter{
            font-size: 54px;
            color: white;
            margin: 10px 7px;
        }
    </style>
</div>

$(文档).ready(函数(){
//用于构造和启动计数器的jquery代码
//已包装在函数中,因此我们可以随时调用它
功能启动计数器(图像加载器){
$('计数器2')。倒计时({
图片:“img/digits.png”,
开始时间:“00:10”,
timerEnd:function(){callback(imageLoader)},
格式:“mm:ss”
})
//在页面加载时立即加载新图像
$('#image').attr('src',imageLoader.nextImage())
}
//每次都照顾好需要做的事情
函数回调(imageLoader){
//替换图像
$('#image').attr('src',imageLoader.nextImage());
//清除已完成的计数器,以便可以在其位置构建新的计数器
$('#counter_2')。空();
//构造一个新计数器并启动它
startCounter(图像加载器);
}
函数ImageLoader(图像){
这个。图像=图像;
this.usedIndex={};
this.displayedCount=0;
}
ImageLoader.prototype.nextImage=函数(){
var self=这个,
len=self.images.length,
UsedIndex=self.UsedIndex,
lastBatchIndex=self.lastBatchIndex,
denyLastBatchIndex=self.displayedCount!==len-1,
指数
if(this.displayedCount==len){
lastBatchIndex=self.lastBatchIndex=self.lastIndex;
UsedIndex=self.UsedIndex={};
self.displayedCount=0;
}
做{
索引=Math.floor(Math.random()*len);
}而(使用索引[index]| |(lastBatchIndex==index&&denyLastBatchIndex));
self.displayedCount++;
UsedIndex[self.lastIndex=index]=true;
返回self.images[索引];
};
//在此数组中填充图像
imageLoader=新的imageLoader(['img/wallps/2.jpg','img/wallps/3.jpg','img/wallps/4.jpg',',
‘img/wallpaps/5.jpg’、‘img/wallpaps/6.jpg’、‘img/wallpaps/7.jpg’、‘img/wallps/9.jpg’,
‘img/wallpaps/10.jpg’、‘img/wallpaps/11.jpg’、‘img/wallpaps/12.jpg’、‘img/wallps/13.jpg’,
‘img/wallpaps/14.jpg’、‘img/wallpaps/15.jpg’、‘img/wallpaps/16.jpg’、‘img/wallps/17.jpg’,
‘img/wallpaps/18.jpg’、‘img/wallps/19.jpg’、‘img/wallps/20.jpg’、‘img/wallps/21.jpg’,
‘img/wallpaps/22.jpg’、‘img/wallpaps/23.jpg’、‘img/wallpaps/24.jpg’、‘img/wallps/25.jpg’,
‘img/wallpaps/26.jpg’、‘img/wallpaps/27.jpg’、‘img/wallpaps/28.jpg’、‘img/wallps/29.jpg’,
‘img/wallpaps/30.jpg’、‘img/wallpaps/31.jpg’、‘img/wallpaps/32.jpg’、‘img/wallps/33.jpg’,
‘img/wallpaps/34.jpg’、‘img/wallpaps/35.jpg’、‘img/wallpaps/36.jpg’、‘img/wallps/37.jpg’,
‘img/wallpaps/38.jpg’、‘img/wallpaps/39.jpg’、‘img/wallpaps/40.jpg’、‘img/wallps/41.jpg’);
//设置所有设置!(构建一个新计数器并启动它)
startCounter(图像加载器);
});
分区计数器{
字体大小:54px;
颜色:白色;
利润率:10px 7px;
}

谢谢

为什么在脚本标签中使用HTML注释?请在@qoolo中发布您的代码,而不是在那里回答问题。如果你不知道他们为什么在那里,那么它不应该在那里,但他们在那里。因此,你可能有一个想法,或者这不是你的代码,在这种情况下,请链接原始。