HTML关于圆形头像的源码

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>圆形头像</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background-color: #000000;
        }
 
        .avatar-container {
            position: relative;
            width: 200px;
            height: 200px;
        }
 
        .avatar {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background-image: url('https://pic.cnblogs.com/avatar/1560763/20181211182317.png'); 
            background-size: cover;
            background-position: center;
            position: relative;
            z-index: 2;
            cursor: grab;
        }
 
        .avatar::before {
            content: '';
            position: absolute;
            top: -2px;
            left: -2px;
            right: -2px;
            bottom: -2px;
            border-radius: 50%;
            background: transparent;
            box-shadow: inset 0 0 0 2px white,
                        0 0 0 4px white;
        }
 
        /* 头像旋转动画 */
        @keyframes rotate {
            from {
                transform: rotate(0deg);
            }
            to {
                transform: rotate(360deg);
            }
        }
 
        /* 自动旋转 */
        .auto-rotate {
            animation: rotate 8s linear infinite;
        }
 
        /* 悬停时停止旋转 */
        .avatar:hover {
            animation-play-state: paused;
        }
    </style>
</head>
<body>
    <div class="avatar-container">
        <div class="avatar auto-rotate"></div>
    </div>
</body>
</html>

 

posted @ 2018-12-13 18:20  CatdeXin  阅读(647)  评论(0)    收藏  举报