简体   繁体   English

身体背景图像淡入

[英]body background-image fade in

I'm trying to replicate the fade in the background image of this site . 我正在尝试在此站点的背景图像中复制淡入淡出。 How would I go about doing so with jQuery? 我将如何使用jQuery?

Use an image as a background image. 将图像用作背景图像。 ie, <img /> tag. <img />标签。 Then use jQuery's .animate() function: 然后使用jQuery的.animate()函数:

$(document).ready(function(){
    $('img.bg').animate({
        opacity: 1;
    }, 1000);
});

CSS: CSS:

.bg {opacity: 0; position: absolute; top: 0; left: 0; width: 100%; height: 100%;}

HTML: HTML:

<img src="bgimage.png" class="bg" />

Working demo http://jsfiddle.net/9HTkV/ (and coz I like hulk) :P 工作演示 http://jsfiddle.net/9HTkV/ (而且我喜欢绿巨人):P

Start with opacity 1 and then make it zero as it is fade in. 从不opacity 1开始,然后随着其淡入度将其设为零。

This should help :) 这应该有帮助:)

code

        $('.box2').animate({
            opacity: 0
        });

​

CSS in start you want Opacity to be 1 and then make it 0. 首先,您希望CSS的不透明度为1,然后使其为0。

.box2 {
    height: 500px;
    width: 700px;
    background: #000000;
    opacity: 1;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM