CSS3 to achieve brilliant image switching effects

Source: Internet
Author: User

  Visit blog to see a very good picture of the switch effect, with CSS3 do, oneself also tried a bit. The idea is ingenious and not difficult to achieve. A picture is divided into four parts, which are absolutely positioned so that each Li displays a portion of the picture, thus creating a complete picture. Animate four parts to show the second picture, and the second image uses the Transform property to zoom in and out of the restore process first.

Effect Preview

Attached Code snippet:
<Divclass= "Grid-box">    <ulclass= "Pic1">        <Li>            <imgsrc= "Image/a.jpg">        </Li>        <Li>            <imgsrc= "Image/a.jpg">        </Li>        <Li>            <imgsrc= "Image/a.jpg">        </Li>        <Li>            <imgsrc= "Image/a.jpg">        </Li>    </ul>    <spanclass= "Pic2"></span></Div>
*{box-sizing:Border-box;margin:0;padding:0;}ul{List-style:None;}. Grid-box{width:280px;Height:220px;Overflow:Hidden;Border:10px Solid Gray;Border-radius:10px;margin:20px Auto;position:relative;}. Pic1,. Pic2{width:260px;Height:200px;position:Absolute; Left:0;Top:0;cursor:Pointer;}. Pic1 Li{width:50%;Height:50%;Overflow:Hidden;float: Left;position:relative;}/*pic1 Stitching Pictures*/. Pic1 li img{position:Absolute;width:260px;Height:200px;}. Grid-box:hover. Pic2,. Pic2,. Pic1 img{transition:All . 7s Ease;}. Pic1 li:nth-of-type (1) img{ Left:0;Top:0;}. Pic1 li:nth-of-type (2) img{ Left:-130px;}. Pic1 li:nth-of-type (3) img{ Left:0;Top:-100px;}. Pic1 li:nth-of-type (4) img{ Left:-130px;Top:-100px;}/*pic1 Sliding Pictures*/. Pic1:hover li:nth-of-type (1) img{/*to decline*/Top:100px;}. Pic1:hover li:nth-of-type (2) img{/*Slide Left*/ Left:-260px;}. Pic1:hover li:nth-of-type (3) img{/*Slide Right*/ Left:130px;}. Pic1:hover li:nth-of-type (4) img{/*Slide Up*/Top:-200px;}/*Amplification of Pic2*/. Pic2{Transform:Scale (1.5);background:URL ("image/b.jpg");background-size:cover;Z-index:-1;}. Grid-box:hover. Pic2{Transform:Scale (1);}

CSS3 to achieve brilliant image switching effects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.