CSS 基础模仿 小米logo

原理:控制margin数值


图片.png

效果:
鼠标移动上去:不知道为什么录屏没有鼠标


小米.gif
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1 {
            width: 55px;
            height: 55px;
            background-color: orange;
            overflow: hidden;
            margin: 100px auto;
        }
        
        .logo::after,
        .logo::before {
            width: 100%;
            height: 100%;
            line-height: 55px;
            font-size: 54px;
            transition: all 0.3s;
        }
        
        .logo::before {
            content: "mi";
        }
        
        .logo::after {
            content: "ho";
            margin-left: 55px;
        }
        
        .box1 .logo:hover::after {
            margin-left: 0;
        }
        
        .box1 .logo:hover::before {
            margin-left: -55PX;
        }
    </style>
</head>

<body>
    <div class="box1">
        <div class="logo"></div>
    </div>
</body>

</html>

本文复习了
overflow 文本溢出
伪元素
transition

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容