简体   繁体   中英

auto zoom in n out CSS (apple-like slideshow effect)

I like pretty much the slow auto zoom in and out effect on that site : http://watchingtheworldcup.com/ for banner images such as the very top one. I tired to replicate it, by looking at developer tools wihtin browser, but have some trouble implementing it as in developper tool some mentions are stroked etc.

here is my html :

 <div class="row">  
     <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
         <a href="#">
             <article class="article_container">
                 <img class="article_image_hompage5" src="#">       
                 <h2 class="article_title_hompage3"> a favourite thai soup</h2>     
             </article>
         </a>
     </div>
 </div>

and my css for the image :

.article_image_hompage5{
    width: 100%;
    border-radius: 2px 2px 2px 2px;
    position:relative;
    display:block;
    margin-left:auto;
    margin-right:auto;
    margin-top:15px;
    z-index:0;
}

Can someone help with with finding the right css settings ? cheers,

Use css animation you can get the similar result.

 /* Chrome, Safari, Opera */ @-webkit-keyframes zoom { from { -webkit-transform: scale(1,1); } to { -webkit-transform: scale(1.5,1.5); } } /* Standard syntax */ @keyframes zoom { from { transform: scale(1,1); } to { transform: scale(1.5,1.5); } } img { -webkit-animation: zoom 50s; /* Chrome, Safari, Opera */ animation: zoom 50s; } 
 <img alt="" src="http://watchingtheworldcup.com/photos/worldcup1.jpg" /> 

If you want to also zoom out you need to define the the milestones in your keyframes as such:

@-webkit-keyframes zoominout {
    0% {
        -webkit-transform: scale(1,1);
    }
    50% {
        -webkit-transform: scale(1.5,1.5);
    }
    100% {
        -webkit-transform: scale(1.1,1.1);
    }
}

Use css transform:scale();

like:

JavaScript:

 window.onload=function(){ $("#content").fadeOut(4000); $("#background").addClass("zoom"); setTimeout(function(){ $("#background").removeClass("zoom"); },5000); } 
 body{ margin:0px; padding:0px; width:100%; height:100%; } #background{ position:absolute; top:0px; left:0px; width:100%; height:100%; background:url("http://watchingtheworldcup.com/photos/worldcup1.jpg") center center no-repeat; background-size: 100% 100%; display:inline-block; z-index:2; transition:all ease 4.1s; /* transform:scale(1,1);*/ } #content{ position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:3; background-color:rgba(0,0,0,0.5); color:#ffffff; font-size:50px; } .zoom{ transform:scale(1.2,1.2); } HTML: 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <div id="background"> </div> <div id="content"> <center><br /><br /><br /><br /><br /><br /> Watching... </center> </div> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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