A simple CSS circular zoom animation

This article is reproduced in: Ape 2048 website ⇨ https://www.mk2048.com/blog/blog.php?id=icj2h2bhhj

The company recently made the logon page, UE students want to have a third-party login icon zoom effect hover round when (the original words are ripple effect -_- ||), the effect of the reference Tencent and Netease news news share button .

  • Share button hover effect Tencent news ( news page ):

    Tencent news Share button hover effect

  • Share button hover effect Netease news ( news page ):

    Share button hover effect Netease news

Looked at the source of these two pages, mostly used transform:scale()and transition, realize their final results are as follows:

Own implementation effect
Achieve general idea is to imitate Netease news, the layout is as follows:

<a href="" class="third-party third-party-weixin">
     <i></i>
     <span></span>
 </a>

A label for the outer container and the overall jump, the inner label i :: before pseudo-element :: after and were used as background and foreground colors, these two elements are pseudo-absolute positioning, vertical and horizontal center,: : after setting scaling properties transform:scale(0), transition animation property transition: all .3s, under normal circumstances :: before seen, when the hover time :: after setting scaling properties transform:scale(1), two neighboring absolutely positioned elements, without setting z-index, the document flow after elements on, and there is a transition animation properties transitionto achieve a zoom animation effects in the case.

span tag for displaying logo, can be a picture or web fonts, as long as it can be transparent, with the pictures here. CSS (using here is sass) as follows:

.third-party {
    position: relative;
    // 为了兼容firefox必须要变成block或inline-block
    display: inline-block;
    width: 48px;
    height: 48px;
    margin: {
        left: 6%;
        right: 6%;
    }
    &:hover {
        i {
            &::after {
                transform: scale(1);
            }
        }
    }
    span {
        // position: relative是为了兼容firefox和IE
        position: relative;
        display: block;
        width: 48px;
        height: 48px;
        background-size: 30px;
        background-position: center;
        background-repeat: no-repeat;
    }
    i {
        position: absolute;
        top: 0;
        left: 0;
        width: 48px;
        height: 48px;
        &::before {
            content: '';
            border-radius: 50%;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
        }
        &::after {
            content: '';
            transition: all .3s;
            border-radius: 50%;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            transform: scale(0);
        }
    }
    &.third-party-weixin {
        span {
            background-image: url(../images/login/weixin-64.png);
        }
        i {
            &::before {
                background-color: #20a839;
            }
            &::after {
                background-color: #30cc54;
            }
        }
    }
}

This very simple circular zoom animation to complete it.

PS: ScreenToGif recorded with GIF nice, recommend.

Guess you like

Origin www.cnblogs.com/jiangshangbulao/p/11791230.html