首页 > 解决方案 > 悬停时的线条边框动画

问题描述

我以前没有见过这种微妙的效果,我想知道是否可以只在 html5/css 中悬停时做这个边框动画。您还发现了其他漂亮的悬停动画效果吗?

https://gfycat.com/evilidefalcon

标签: htmlcss

解决方案


您可以使用 ":hover" 示例执行此操作: elemnt:hover

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>cool animation</title>
    <style>
        .test1 {
            /* Just centering the text */
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            /* adding transition */
            transition: 0.6s all;
        }
        /* using the hover method */
        .test1:hover {
            /* here you can specify whatever you want */
            border: 2px solid black;
        }
    </style>
</head>
<body>
    <h2 class="test1">test</h2>
</body>
</html>

推荐阅读