前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CSS 3.0实现特效评分栏

CSS 3.0实现特效评分栏

作者头像
越陌度阡
发布2020-11-26 10:14:52
8650
发布2020-11-26 10:14:52
举报

给大家分享一个用CSS 3.0实现的特效评分栏,效果如下:

在这里插入图片描述
在这里插入图片描述

以下是代码实现,欢迎大家复制粘贴和收藏。

代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS 3.0实现特效评分栏</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            font-family: '微软雅黑', sans-serif;
            box-sizing: border-box;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #20152d;
        }

        .rating {
            position: relative;
            display: flex;
            flex-direction: row-reverse;
        }

        .rating input {
            display: none;
        }

        .rating label {
            position: relative;
            width: 0;
            height: 120px;
            cursor: pointer;
            transition: 0.5s;
            filter: grayscale(1);
            opacity: 0;
        }

        .rating:hover label {
            width: 160px;
            opacity: 0.2;
        }

        .rating input:hover+label,
        .rating input:checked+label {
            filter: grayscale(0);
            opacity: 1;
            width: 160px;
        }

        .rating label h4 {
            color: #fff;
            font-style: 24px;
            padding-top: 10px;
            margin-left: 40px;
            font-weight: 500;
            white-space: nowrap;
            opacity: 0;
            transform: translateY(-50px) scale(0);
            transition: 0.5s
        }

        .rating input:hover+label h4,
        .rating input:checked+label h4 {
            opacity: 1;
            transform: translateY(0px) scale(1);
        }

        .text {
            position: absolute;
            top: -150px;
            left: 50%;
            transform: translateX(-50%);
            color: #fff;
            width: 500px;
            font-weight: 700;
            letter-spacing: 2px;
            text-align: center;
            white-space: nowrap;
            font-size: 36px;
        }
    </style>
</head>

<body>
    <div class="rating">
        <input type="radio" name="star" id="star1" checked>
        <label for="star1">
            <img src="5.png" alt="">
            <h4>优秀</h4>
        </label>
        <input type="radio" name="star" id="star2">
        <label for="star2">
            <img src="4.png" alt="">
            <h4>满意</h4>
        </label>
        <input type="radio" name="star" id="star3">
        <label for="star3">
            <img src="3.png" alt="">
            <h4>一般</h4>
        </label>
        <input type="radio" name="star" id="star4">
        <label for="star4">
            <img src="2.png" alt="">
            <h4>差评</h4>
        </label>
        <input type="radio" name="star" id="star5">
        <label for="star5">
            <img src="1.png" alt="">
            <h4>讨厌</h4>
        </label>
        <div class="text">你喜欢这个系列的课程吗?</div>
    </div>
</body>

</html>

以下是上面代码中引入的图片。

1.png

2.png

3.png

4.png

5.png

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/06/03 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档