笑脸变哭脸

 

项目实现


通过代码实现笑脸哭脸的转变,先建立div块,分别命名为脸,左眼,右眼,眼球,嘴巴,再依次确定他们的位置,整张脸处于页面中间的位置,通过css设置样式,脸的大小,背景颜色和位置,眼睛的大小和在脸部的位置,嘴巴的位大小,位置和弯曲方向,当鼠标放置在脸部时候脸部背景颜色改变,当鼠标放在嘴巴上的时候嘴巴的弯曲方向改变,从而实现笑脸到哭脸的转变。


f427a9093e7e4445a1bccdf9032c5c7f.png

 23bd15eb60904ae8969f6663a976a858.png

71372ebd4ece462ba7ae28253ee1e869.png 


 代码

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            *{
                margin: 0;
                padding: 0;
            }
            .face {
                width: 600px;
                height: 600px;
                background-image: radial-gradient(#cc0,orange);
                border-radius: 50%;
                margin: 50px auto;
                position: relative;
            }
            .face:hover {
                background: blueviolet;
            }
            .eye {
                width: 150px;
                height: 150px;
                background-color: #fff;
                border-radius: 50%;
                position: absolute;
                top: 150px;
                
            }
            .left {
                left: 100px;
            }
            .right {
                right: 100px;
            }
            .ball {
                width: 50px;
                height: 50px;
                background-color: #000;
                border-radius: 50%;
                position: absolute;
                top: 100px;
                left: 50px;
                bottom: 0;
            }
            .mouth {
                width: 200px;
                height: 80px;
                border-radius: 50%;
                border-bottom: 5px solid red;
                position: absolute;
                left: 200px;
                bottom: 100px;
            }
            .mouth:hover  {
                border-bottom: 5px solid blueviolet;
                border-top: 5px solid red;
            }
        </style>
    </head>
    <body>
        <h2 align="middle">笑脸变哭脸</h2>
        <div class="face">
            <div class="eye left">
                <div class="ball"></div>
                
            </div>
            <div class="eye right">
            <div class="ball"></div>
        </div>
        <div class="mouth"></div>
        </div>
        
    </body>
</html>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

weixin_74817181

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值