How to zoom a div in on page load with jQuery?

后端 未结 3 1706
被撕碎了的回忆
被撕碎了的回忆 2021-01-07 04:42

Is there a way to make a div zoom-in when the page loads? Like when you install a new app in Chrome, it brings you to the new tab page and zooms in the new app. It looks nic

相关标签:
3条回答
  • 2021-01-07 04:59

    You will need to zoom-in everything inside the DIV, like images, increase text size, etc...

    Maybe there are zooming plugins for jQuery.

    0 讨论(0)
  • 2021-01-07 05:03

    here's one way to zoom with jQuery

    example jsfiddle

    set starting sizes (and position offset with top & left) in your CSS:

    #zoom-box {
        background: #7d7e7d;
        background: linear-gradient(top, #7d7e7d 0%,#0e0e0e 100%);
        border-radius:10px;
        width:0;
        height:0;
        position:relative;
        top:150px;
        left:150px;
        border:solid 4px yellow;
        font-size:0;
        line-height:0;
        vertical-align:middle;
        text-align:center;
        color:#fff;
    }
    

    then size everything up with a jQuery animate() method

    $('#zoom-box').animate({
        width:'300px',
        height:'300px',
        top:'0',
        left:'0',
        'font-size':'50px',
        'line-height':'300px'
    }, 1000);
    
    0 讨论(0)
  • 2021-01-07 05:06

    CSS:

    div {
        width:50px;
        height:50px;
        margin:20px;
        background-color:red;
        font-size:1em;
    }
    
    .big {
        width:100px;
        height:100px;
        font-size:2em;
    }
    

    JQuery (with JQueryUI):

    $(function(){
          $('#my_div').addClass("big",500).removeClass("big",500);
    });
    

    Here's the demo: http://jsfiddle.net/tjRvn/

    Unfortunately addClass() with the duration is not working in Chrome tonight. Weird :/

    0 讨论(0)
提交回复
热议问题