<h1>Hover Me</h1>
HTML
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
<head> ... </head>
<body>
</body>
CSS
格式化
h1 {
position: relative;
font-size: 4em;
}
h1::before {
transform: scaleX(0);
transform-origin: bottom right;
}
h1:hover::before {
transform: scaleX(1);
transform-origin: bottom left;
}
h1::before {
content: " ";
display: block;
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
inset: 0 0 0 0;
background: #FF69B4;
z-index: -1;
transition: transform .25s ease;
}
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #ffe;
}
JS
格式化