hooyantsing's Blog

P164_13_开发缩放菜单案例

字数统计: 282阅读时长: 1 min
2020/04/22

P164 13 开发缩放菜单案例

transform-origin

缩放基点。

默认位于中心。

3684d221cc34f74143b904a82fb262b0.png

例:

1
2
//改变至左上角
transform-origin: left top;

5c18a741d842cab8307c598df8d1da12.png

实战案例

3c31386b39807df8fa900d5cf6ab269a.png

源码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }
        main{
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);

        }
        ul{
            display: flex;
            flex-direction: row;
            list-style-type: none;
        }
        ul li{
            margin-right: 10px;
        }
        ul li strong{
            position: relative;
            padding: 5px 30px;
            background: #27ae60;
            text-transform: uppercase;
            cursor: pointer;
            z-index: 1;
        }
        ul li strong + div{
            display: flex;
            flex-direction: column;
            background: #95a5a6;
            padding: 10px;
            transform: scale(0);
            transition: .6s;
        }
        ul li strong + div a{
            color: white;
            text-decoration: none;
        }
        ul li:hover  strong + div{
            transform: scale(1);
        }
    </style>
</head>
<body>
<main>
    <ul>
        <li>
            <strong>video</strong>
            <div>
                <a href="">HDCMS</a>
                <a href="">PHP</a>
            </div>
        </li>
        <li>
            <strong>live</strong>
            <div>
                <a href="">LINUX</a>
                <a href="">CSS</a>
            </div>
        </li>
    </ul>
</main>
</body>
</html>
CATALOG