DOM加载时背景稍微缩放? [英] Slight background zoom on DOM load?

查看:74
本文介绍了DOM加载时背景稍微缩放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在此网站上重现效果:

How to reproduce the effect on this website :

https://shop.stripe.com/

我的意思是在显示任何内容之前等待DOM完全加载,然后将背景图像缩小1秒.很酷.

I mean waiting for the DOM to fully load before showing anything, and then having the background image zooming out for 1s. Pretty cool.

推荐答案

这是通过使用不同的过渡和变换来完成的.演示: http://jsfiddle.net/lotusgodkk/eHAuh/2/

It's done using different transition and transforms together. Demo: http://jsfiddle.net/lotusgodkk/eHAuh/2/

关键是要添加/删除document.ready

HTML:

<div id="DIV_1" class="scaled"></div>

JS:

$(document).ready(function () {
    $('#DIV_1').attr('class', 'animatable');
    setTimeout(function () {
        $('#DIV_1').removeClass('animatable');
    }, 1000)
});

CSS:

#DIV_1 {
    background-position: 50% 50%;
    bottom: 0px;
    height: 472px;
    left: 0px;
    position: absolute;
    right: 0px;
    top: 0px;
    width: 600px;
    z-index: 1;
    background: rgba(0, 0, 0, 0) url(https://shop.stripe.com/assets/images/showcase/thairu-kat.jpg) no-repeat scroll 50% 50% / cover padding-box border-box;
    font: normal normal normal 16px/normal Helvetica, Arial, sans-serif;
    zoom:1.1;
    background-size:cover;
}
/*#DIV_1*/
 .animatable {
    -webkit-transition:all 750ms ease-out;
    transition:all 750ms ease-out;
}
.scaled {
    -webkit-transform:scale(1.02);
    transform:scale(1.02);
}

这篇关于DOM加载时背景稍微缩放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆