CSS+transform画动态表情

先给大家看下画完后是什么样子:

代码看这里:

html代码:

<body>
    <div class="emoji  emoji_like">
        <div class="emoji_hand">
            <div class="emoji_thumb"></div>
        </div>
    </div>
    <div class="emoji  emoji_love">
        <div class="emoji_heart"></div>
    </div>
    <div class="emoji  emoji_haha">
        <div class="emoji_face">
            <div class="emoji_eyes"></div>
            <div class="emoji_mouth">
                <div class="emoji_tongue"></div>
            </div>
        </div>
    </div>
    <div class="emoji  emoji_yay">
        <div class="emoji_face">
            <div class="emoji_eyebrows"></div>
            <div class="emoji_mouth"></div>
        </div>
    </div>
    <div class="emoji  emoji_wow">
        <div class="emoji_face">
            <div class="emoji_eyebrows"></div>
            <div class="emoji_eyes"></div>
            <div class="emoji_mouth"></div>
        </div>
    </div>
    <div class="emoji  emoji_sad">
        <div class="emoji_face">
            <div class="emoji_eyebrows"></div>
            <div class="emoji_eyes"></div>
            <div class="emoji_mouth"></div>
        </div>
    </div>
    <div class="emoji  emoji_angry">
        <div class="emoji_face">
            <div class="emoji_eyebrows"></div>
            <div class="emoji_eyes"></div>
            <div class="emoji_mouth"></div>
        </div>
    </div>    <div><a href="http://www.cnblogs.com/yingzi1028/"></a></div>
</body>

css代码:

    <style>
        body {
            text-align: center;
            margin: 80px auto 0;
            font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
        }

        .emoji {
            width: 120px;
            height: 120px;
            margin: 15px;
            background: #FFDA6A;
            display: inline-block;
            border-radius: 50%;
            position: relative;
        }

        .emoji:after {
            position: absolute;
            bottom: -40px;
            font-size: 18px;
            width: 60px;
            left: calc(50% - 30px);
            color: #8A8A8A;
        }

        .emoji_face,
        .emoji_eyebrows,
        .emoji_eyes,
        .emoji_mouth,
        .emoji_tongue,
        .emoji_heart,
        .emoji_hand,
        .emoji_thumb {
            position: absolute;
        }

        .emoji_face:before,
        .emoji_face:after,
        .emoji_eyebrows:before,
        .emoji_eyebrows:after,
        .emoji_eyes:before,
        .emoji_eyes:after,
        .emoji_mouth:before,
        .emoji_mouth:after,
        .emoji_tongue:before,
        .emoji_tongue:after,
        .emoji_heart:before,
        .emoji_heart:after,
        .emoji_hand:before,
        .emoji_hand:after,
        .emoji_thumb:before,
        .emoji_thumb:after {
            position: absolute;
            content: ‘‘;
        }

        .emoji_face {
            width: inherit;
            height: inherit;
        }

        .emoji_like {
            background: #fdbfca;
        }

        .emoji_like:after {
            content: ‘Like‘;
        }

        .emoji_like .emoji_hand {
            left: 25px;
            bottom: 30px;
            width: 20px;
            height: 40px;
            background: #FFFFFF;
            border-radius: 5px;
            z-index: 0;
            animation: hands-up 2s linear infinite;
        }

        .emoji_like .emoji_hand:before {
            left: 25px;
            bottom: 5px;
            width: 40px;
            background: inherit;
            height: 10px;
            border-radius: 2px 10px 10px 2px;
            box-shadow: 1px -9px 0 1px #FFFFFF, 2px -19px 0 2px #FFFFFF, 3px -29px 0 3px #FFFFFF;
        }

        .emoji_like .emoji_thumb {
            border-bottom: 20px solid #FFFFFF;
            border-left: 20px solid transparent;
            top: -25px;
            right: -25px;
            z-index: 2;
            transform: rotate(5deg);
            transform-origin: 0% 100%;
            animation: thumbs-up 2s linear infinite;
        }

        .emoji_like .emoji_thumb:before {
            border-radius: 50% 50% 0 0;
            background: #FFFFFF;
            width: 10px;
            height: 12px;
            left: -10px;
            top: -8px;
            transform: rotate(-15deg);
            transform-origin: 100% 100%;
            box-shadow: -1px 4px 0 -1px #FFFFFF;
        }

        .emoji_love {
            background: #fdbfca;
        }

        .emoji_love:after {
            content: ‘Love‘;
        }

        .emoji_love .emoji_heart {
            left: calc(50% - 40px);
            top: calc(50% - 40px);
            width: 80px;
            height: 80px;
            animation: heart-beat 1s linear infinite alternate;
        }

        .emoji_love .emoji_heart:before,
        .emoji_love .emoji_heart:after {
            left: calc(50% - 20px);
            top: calc(50% - 32px);
            width: 40px;
            height: 64px;
            background: #fdf81f;
            border-radius: 20px 20px 0 0;
        }

        .emoji_love .emoji_heart:before {
            transform: translate(20px) rotate(-45deg);
            transform-origin: 0 100%;
        }

        .emoji_love .emoji_heart:after {
            transform: translate(-20px) rotate(45deg);
            transform-origin: 100% 100%;
        }

        .emoji_haha:after {
            content: ‘Haha‘;
        }

        .emoji_haha .emoji_face {
            animation: haha-face 2s linear infinite;
        }

        .emoji_haha .emoji_eyes {
            width: 26px;
            height: 6px;
            border-radius: 2px;
            left: calc(50% - 13px);
            top: 35px;
            transform: rotate(20deg);
            background: transparent;
            box-shadow: -25px 5px 0 0 #000000, 25px -5px 0 0 #000000;
        }

        .emoji_haha .emoji_eyes:after {
            left: 0;
            top: 0;
            width: 26px;
            height: 6px;
            border-radius: 2px;
            transform: rotate(-40deg);
            background: transparent;
            box-shadow: -25px -5px 0 0 #000000, 25px 5px 0 0 #000000;
        }

        .emoji_haha .emoji_mouth {
            width: 80px;
            height: 40px;
            left: calc(50% - 40px);
            top: 50%;
            background: #000000;
            border-radius: 0 0 40px 40px;
            overflow: hidden;
            z-index: 1;
            animation: haha-mouth 2s linear infinite;
        }

        .emoji_haha .emoji_tongue {
            width: 70px;
            height: 30px;
            background: #F55064;
            left: calc(50% - 35px);
            bottom: -10px;
            border-radius: 50%;
        }

        .emoji_yay:after {
            content: ‘Yay‘;
            animation: yay-reverse 1s linear infinite;
        }

        .emoji_yay .emoji_face {
            animation: yay 1s linear infinite alternate;
        }

        .emoji_yay .emoji_eyebrows {
            left: calc(50% - 3px);
            top: 30px;
            height: 6px;
            width: 6px;
            border-radius: 50%;
            background: transparent;
            box-shadow: -6px 0 0 0 #000000, -36px 0 0 0px #000000, 6px 0 0 0 #000000, 36px 0 0 0px #000000;
        }

        .emoji_yay .emoji_eyebrows:before,
        .emoji_yay .emoji_eyebrows:after {
            width: 36px;
            height: 18px;
            border-radius: 60px 60px 0 0;
            background: transparent;
            border: 6px solid black;
            box-sizing: border-box;
            border-bottom: 0;
            bottom: 3px;
            left: calc(50% - 18px);
        }

        .emoji_yay .emoji_eyebrows:before {
            margin-left: -21px;
        }

        .emoji_yay .emoji_eyebrows:after {
            margin-left: 21px;
        }

        .emoji_yay .emoji_mouth {
            top: 60px;
            background: transparent;
            left: 50%;
        }

        .emoji_yay .emoji_mouth:after {
            width: 80px;
            height: 80px;
            left: calc(50% - 40px);
            top: -75px;
            border-radius: 50%;
            background: transparent;
            border: 6px solid #000000;
            box-sizing: border-box;
            border-top-color: transparent;
            border-left-color: transparent;
            border-right-color: transparent;
            z-index: 1;
        }

        .emoji_yay .emoji_mouth:before {
            width: 6px;
            height: 6px;
            background: transparent;
            border-radius: 50%;
            bottom: 5px;
            left: calc(50% - 3px);
            box-shadow: -25px 0 0 0 #000000, 25px 0 0 0 #000000, -35px -2px 30px 10px #D5234C, 35px -2px 30px 10px #D5234C;
        }

        .emoji_wow:after {
            content: ‘Wow‘;
        }

        .emoji_wow .emoji_face {
            animation: wow-face 3s linear infinite;
        }

        .emoji_wow .emoji_eyebrows {
            left: calc(50% - 3px);
            height: 6px;
            width: 6px;
            border-radius: 50%;
            background: transparent;
            box-shadow: -18px 0 0 0 #000000, -33px 0 0 0 #000000, 18px 0 0 0 #000000, 33px 0 0 0 #000000;
            animation: wow-brow 3s linear infinite;
        }

        .emoji_wow .emoji_eyebrows:before,
        .emoji_wow .emoji_eyebrows:after {
            width: 24px;
            height: 20px;
            border: 6px solid #000000;
            box-sizing: border-box;
            border-radius: 50%;
            border-bottom-color: transparent;
            border-left-color: transparent;
            border-right-color: transparent;
            top: -3px;
            left: calc(50% - 12px);
        }

        .emoji_wow .emoji_eyebrows:before {
            margin-left: -25px;
        }

        .emoji_wow .emoji_eyebrows:after {
            margin-left: 25px;
        }

        .emoji_wow .emoji_eyes {
            width: 16px;
            height: 24px;
            left: calc(50% - 8px);
            top: 35px;
            border-radius: 50%;
            background: transparent;
            box-shadow: 25px 0 0 0 #000000, -25px 0 0 0 #000000;
        }

        .emoji_wow .emoji_mouth {
            width: 30px;
            height: 45px;
            left: calc(50% - 15px);
            top: 50%;
            border-radius: 50%;
            background: #000000;
            animation: wow-mouth 3s linear infinite;
        }

        .emoji_sad:after {
            content: ‘Sad‘;
        }

        .emoji_sad .emoji_face {
            animation: sad-face 2s ease-in infinite;
        }

        .emoji_sad .emoji_eyebrows {
            left: calc(50% - 3px);
            top: 35px;
            height: 6px;
            width: 6px;
            border-radius: 50%;
            background: transparent;
            box-shadow: -40px 9px 0 0 #000000, -25px 0 0 0 #000000, 25px 0 0 0 #000000, 40px 9px 0 0 #000000;
        }

        .emoji_sad .emoji_eyebrows:before,
        .emoji_sad .emoji_eyebrows:after {
            width: 30px;
            height: 20px;
            border: 6px solid #000000;
            box-sizing: border-box;
            border-radius: 50%;
            border-bottom-color: transparent;
            border-left-color: transparent;
            border-right-color: transparent;
            top: 2px;
            left: calc(50% - 15px);
        }

        .emoji_sad .emoji_eyebrows:before {
            margin-left: -30px;
            transform: rotate(-30deg);
        }

        .emoji_sad .emoji_eyebrows:after {
            margin-left: 30px;
            transform: rotate(30deg);
        }

        .emoji_sad .emoji_eyes {
            width: 14px;
            height: 16px;
            left: calc(50% - 7px);
            top: 50px;
            border-radius: 50%;
            background: transparent;
            box-shadow: 25px 0 0 0 #000000, -25px 0 0 0 #000000;
        }

        .emoji_sad .emoji_eyes:after {
            background: #548DFF;
            width: 12px;
            height: 12px;
            margin-left: 6px;
            border-radius: 0 100% 40% 50% / 0 50% 40% 100%;
            transform-origin: 0% 0%;
            animation: tear-drop 2s ease-in infinite;
        }

        .emoji_sad .emoji_mouth {
            width: 60px;
            height: 80px;
            left: calc(50% - 30px);
            top: 80px;
            box-sizing: border-box;
            border: 6px solid #000000;
            border-radius: 50%;
            border-bottom-color: transparent;
            border-left-color: transparent;
            border-right-color: transparent;
            background: transparent;
            animation: sad-mouth 2s ease-in infinite;
        }

        .emoji_sad .emoji_mouth:after {
            width: 6px;
            height: 6px;
            background: transparent;
            border-radius: 50%;
            top: 4px;
            left: calc(50% - 3px);
            box-shadow: -18px 0 0 0 #000000, 18px 0 0 0 #000000;
        }

        .emoji_angry {
            background: linear-gradient(#D5234C -10%, #FFDA6A);
            background-size: 100%;
            animation: angry-color 2s ease-in infinite;
        }

        .emoji_angry:after {
            content: ‘Angry‘;
        }

        .emoji_angry .emoji_face {
            animation: angry-face 2s ease-in infinite;
        }

        .emoji_angry .emoji_eyebrows {
            left: calc(50% - 3px);
            top: 55px;
            height: 6px;
            width: 6px;
            border-radius: 50%;
            background: transparent;
            box-shadow: -44px 5px 0 0 #000000, -7px 16px 0 0 #000000, 7px 16px 0 0 #000000, 44px 5px 0 0 #000000;
        }

        .emoji_angry .emoji_eyebrows:before,
        .emoji_angry .emoji_eyebrows:after {
            width: 50px;
            height: 20px;
            border: 6px solid #000000;
            box-sizing: border-box;
            border-radius: 50%;
            border-top-color: transparent;
            border-left-color: transparent;
            border-right-color: transparent;
            top: 0;
            left: calc(50% - 25px);
        }

        .emoji_angry .emoji_eyebrows:before {
            margin-left: -25px;
            transform: rotate(15deg);
        }

        .emoji_angry .emoji_eyebrows:after {
            margin-left: 25px;
            transform: rotate(-15deg);
        }

        .emoji_angry .emoji_eyes {
            width: 12px;
            height: 12px;
            left: calc(50% - 6px);
            top: 70px;
            border-radius: 50%;
            background: transparent;
            box-shadow: 25px 0 0 0 #000000, -25px 0 0 0 #000000;
        }

        .emoji_angry .emoji_mouth {
            width: 36px;
            height: 18px;
            left: calc(50% - 18px);
            bottom: 15px;
            background: #000000;
            border-radius: 50%;
            animation: angry-mouth 2s ease-in infinite;
        }

        @keyframes heart-beat {
            25% {
                transform: scale(1.1);
            }
            75% {
                transform: scale(0.6);
            }
        }

        @keyframes haha-face {
            10% {
                transform: translateY(25px);
            }
            20% {
                transform: translateY(15px);
            }
            30% {
                transform: translateY(25px);
            }
            40% {
                transform: translateY(15px);
            }
            50% {
                transform: translateY(25px);
            }
            60% {
                transform: translateY(0);
            }
            70% {
                transform: translateY(-10px);
            }
            80% {
                transform: translateY(0);
            }
            90% {
                transform: translateY(-10px);
            }
        }

        @keyframes haha-mouth {
            10% {
                transform: scale(0.6);
                top: 45%;
            }
            20% {
                transform: scale(0.8);
                top: 45%;
            }
            30% {
                transform: scale(0.6);
                top: 45%;
            }
            40% {
                transform: scale(0.8);
                top: 45%;
            }
            50% {
                transform: scale(0.6);
                top: 45%;
            }
            60% {
                transform: scale(1);
                top: 50%;
            }
            70% {
                transform: scale(1.2);
                top: 50%;
            }
            80% {
                transform: scale(1);
                top: 50%;
            }
            90% {
                transform: scale(1.1);
                top: 50%;
            }
        }

        @keyframes yay {
            25% {
                transform: rotate(-15deg);
            }
            75% {
                transform: rotate(15deg);
            }
        }

        @keyframes wow-face {
            15%,
            25% {
                transform: rotate(20deg) translateX(-25px);
            }
            45%,
            65% {
                transform: rotate(-20deg) translateX(25px);
            }
            75%,
            100% {
                transform: rotate(0deg) translateX(0);
            }
        }

        @keyframes wow-brow {
            15%,
            65% {
                top: 25px;
            }
            75%,
            100%,
            0% {
                top: 15px;
            }
        }

        @keyframes wow-mouth {
            10%,
            30% {
                width: 20px;
                height: 20px;
                left: calc(50% - 10px);
            }
            50%,
            70% {
                width: 30px;
                height: 40px;
                left: calc(50% - 15px);
            }
            75%,
            100% {
                height: 50px;
            }
        }

        @keyframes sad-face {
            25%,
            35% {
                top: -15px;
            }
            55%,
            95% {
                top: 10px;
            }
            100%,
            0% {
                top: 0;
            }
        }

        @keyframes sad-mouth {
            25%,
            35% {
                transform: scale(0.85);
                top: 70px;
            }
            55%,
            100%,
            0% {
                transform: scale(1);
                top: 80px;
            }
        }

        @keyframes tear-drop {
            0%,
            100% {
                display: block;
                left: 35px;
                top: 15px;
                transform: rotate(45deg) scale(0);
            }
            25% {
                display: block;
                left: 35px;
                transform: rotate(45deg) scale(2);
            }
            49.9% {
                display: block;
                left: 35px;
                top: 65px;
                transform: rotate(45deg) scale(0);
            }
            50% {
                display: block;
                left: -35px;
                top: 15px;
                transform: rotate(45deg) scale(0);
            }
            75% {
                display: block;
                left: -35px;
                transform: rotate(45deg) scale(2);
            }
            99.9% {
                display: block;
                left: -35px;
                top: 65px;
                transform: rotate(45deg) scale(0);
            }
        }

        @keyframes hands-up {
            25% {
                transform: rotate(15deg);
            }
            50% {
                transform: rotate(-15deg) translateY(-10px);
            }
            75%,
            100% {
                transform: rotate(0deg);
            }
        }

        @keyframes thumbs-up {
            25% {
                transform: rotate(20deg);
            }
            50%,
            100% {
                transform: rotate(5deg);
            }
        }

        @keyframes angry-color {
            45%,
            60% {
                background-size: 250%;
            }
            85%,
            100%,
            0% {
                background-size: 100%;
            }
        }

        @keyframes angry-face {
            35%,
            60% {
                transform: translateX(0) translateY(10px) scale(0.9);
            }
            40% {
                transform: translateX(-5px) translateY(10px) scale(0.9);
            }
            45% {
                transform: translateX(5px) translateY(10px) scale(0.9);
            }
            50% {
                transform: translateX(-5px) translateY(10px) scale(0.9);
            }
            55% {
                transform: translateX(5px) translateY(10px) scale(0.9);
            }
        }

        @keyframes angry-mouth {
            25%,
            50% {
                height: 6px;
                bottom: 25px;
            }
        }
    </style>
时间: 2024-10-01 06:55:02

CSS+transform画动态表情的相关文章

[css]我要用css画幅画

几年前开始就一直想用css画幅画. 今天才真正开始, 从简单的开始. 作为一个工作压力那么大的程序员,我首先要画一个太阳. html如下: 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Css Paint</title> 6 <link rel="stylesheet

[css]我要用css画幅画(二)

接着之前的[css]我要用css画幅画(一) , 今天,我又画一个房子,很简单,屋顶.墙壁.门. 现在开始,做得效果都只兼容chrome,所以下面的css3的属性可能只有-webkit-前缀. 我只是为了兴趣画画, 何必理会兼容性呢,是吧? html如下: 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title

[css]我要用css画幅画(四)

接着之前的[css]我要用css画幅画(三), 今天,我画了两朵云,并给小明介绍了个朋友:静静. github:https://github.com/bee0060/Css-Paint , 完整代码在pages/sun-house-4.html和相关的css中可以找到 demo: http://bee0060.github.io/Css-Paint/pages/sun-house-4.html 完整html如下: 1 <!DOCTYPE html> 2 <html lang="

[css]我要用css画幅画(七) - 哆啦A梦

接着之前的[css]我要用css画幅画(六),今天画的有所不同,画的是哆啦A梦,我们小时候对他的称呼其实是小叮当机器猫. (PS:这次我要做的事情,很多人已经做过,这并不是什么创新,我只是在学习并记录下学习的过程) 这次就不多说CSS属性的基础概念了. 说说我画的过程吧, 好,进入正题. 因为和之前的瞎画不同,这次是画现有的东西.我认为临摹是比较简单的. 我先上网找了下要临摹的对象,找了个最中规中矩的图片,如下: 这对我来说不是一个简单的任务, 而我处理不简单的任务的解决方案,就是把他拆分再拆分

Excel2010画动态甘特图

哈哈!你居然真的看简介点进来啦,我也想八一八Henry gantt本人的故事,可是我查了好些资料,一个槽点都没有发现,不过人生经历还是可以了解下: 此人活了58年,生前是一个中规中距的机械工程师&项目管理(PM),活在资本主义螺丝钉,发表过几篇不痛不痒关于项目管理方面的论文和书,可是(人生大转折哇) 在55岁那一年,积累了那么多年的经验,终于顿悟,发明了gantt图,并于同一年发表了 Industrial leadership, 再之后,夜以继日(脑补剧情)地工作,终于在58岁那年又发表了一篇p

[css]我要用css画幅画(五)

接着之前的[css]我要用css画幅画(四), 这次我给小明和静静增加了对话,用了简单的动画效果. github:https://github.com/bee0060/Css-Paint , 完整代码在pages/sun-house-4.html和相关的css中可以找到 demo: http://bee0060.github.io/Css-Paint/pages/sun-house-5.html 完整html如下: 1 <!DOCTYPE html> 2 <html lang="

[css]我要用css画幅画(九) - Apple Logo

接着之前的[css]我要用css画幅画(八) - Hello Kitty,这次画的是苹果公司的logo 这次打算将分析和实现步骤尽量详细的说一说. 其实之前的也打算详细讲分析和设计过程,不过之前的图比较复杂,如果讲那么细,真是怕要讲到猴年马月. 这次的图足够简单,就拿这个图来说明. 都是一些简单的基本方法,通过举一反三,可以实现大部分效果. Github Demo:http://bee0060.github.io/Css-Paint/pages/logo/apple.html Code Pen

可在广域网部署运行的QQ高仿版 -- GG2014 完美版!新增支持:聊天记录、好友分组、托盘闪动消息提醒、登录状态、GIF动态表情

距上次GG V3.7版本(可在广域网部署运行的QQ高仿版 -- GG叽叽V3.7,优化视频聊天.控制更多相关细节)的发布,已经有50天了,这50天对于GG来说,是一个重大的飞跃.因为这段时间通过一些基于GG的实战项目,发现了GG的很多bug和不足之处,我都一一做了修正,并增加了一些基础且必须的功能.这次发布的是GG V4.0版本,又称为GG 2014. 记得在GG早期版本时,园子里的吉日兄跟我留言说:"GG完全不能正式使用......",那时我还不是很服气,后来当我基于GG开发正式项目

安卓即时通讯聊天界面及动态表情实现

最近因工作需要,一直在研究即时通讯,偶尔在网上看到一篇介绍发送类似qq动态表情的文章,觉得很不错,于是经过本人的整理及改善,做成一个demo,供大家一块研究学习,界面及功能如下: 其中接收的消息是在自己发送消息后模拟对方发来的消息已达到效果,具体可下载demo研究,里面的注释也比较清楚,有这方面需求的同学可以简单的学习下其布局,收发消息后的处理以及发送表情等的实现过程. 源码地址:http://download.csdn.net/detail/baiyuliang2013/7973133