html加五星

效果如下图
在这里插入图片描述
在这里插入图片描述

1.这里是style样式

* {
    box-sizing: border-box;
}


.rating {
    display: flex;
    width: 100%;
    justify-content: left;
    overflow: hidden;
    flex-direction: row-reverse;
    height: 40px;
    position: relative;
}

.rating-0 {
    -webkit-filter: grayscale(100%);
    filter: grayscale(100%);
}

.rating > input {
    display: none;
}

.rating > label {
    cursor: pointer;
    width: 40px;
    height: 40px;
    margin-top: auto;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='126.729' height='126.73'%3e%3cpath fill='%23e3e3e3' d='M121.215 44.212l-34.899-3.3c-2.2-.2-4.101-1.6-5-3.7l-12.5-30.3c-2-5-9.101-5-11.101 0l-12.4 30.3c-.8 2.1-2.8 3.5-5 3.7l-34.9 3.3c-5.2.5-7.3 7-3.4 10.5l26.3 23.1c1.7 1.5 2.4 3.7 1.9 5.9l-7.9 32.399c-1.2 5.101 4.3 9.3 8.9 6.601l29.1-17.101c1.9-1.1 4.2-1.1 6.1 0l29.101 17.101c4.6 2.699 10.1-1.4 8.899-6.601l-7.8-32.399c-.5-2.2.2-4.4 1.9-5.9l26.3-23.1c3.8-3.5 1.6-10-3.6-10.5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 76%;
    transition: .3s;
}

.rating > input:checked ~ label,
.rating > input:checked ~ label ~ label {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='126.729' height='126.73'%3e%3cpath fill='%23fcd93a' d='M121.215 44.212l-34.899-3.3c-2.2-.2-4.101-1.6-5-3.7l-12.5-30.3c-2-5-9.101-5-11.101 0l-12.4 30.3c-.8 2.1-2.8 3.5-5 3.7l-34.9 3.3c-5.2.5-7.3 7-3.4 10.5l26.3 23.1c1.7 1.5 2.4 3.7 1.9 5.9l-7.9 32.399c-1.2 5.101 4.3 9.3 8.9 6.601l29.1-17.101c1.9-1.1 4.2-1.1 6.1 0l29.101 17.101c4.6 2.699 10.1-1.4 8.899-6.601l-7.8-32.399c-.5-2.2.2-4.4 1.9-5.9l26.3-23.1c3.8-3.5 1.6-10-3.6-10.5z'/%3e%3c/svg%3e");
}

.rating > input:not(:checked) ~ label:hover,
.rating > input:not(:checked) ~ label:hover ~ label {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='126.729' height='126.73'%3e%3cpath fill='%23d8b11e' d='M121.215 44.212l-34.899-3.3c-2.2-.2-4.101-1.6-5-3.7l-12.5-30.3c-2-5-9.101-5-11.101 0l-12.4 30.3c-.8 2.1-2.8 3.5-5 3.7l-34.9 3.3c-5.2.5-7.3 7-3.4 10.5l26.3 23.1c1.7 1.5 2.4 3.7 1.9 5.9l-7.9 32.399c-1.2 5.101 4.3 9.3 8.9 6.601l29.1-17.101c1.9-1.1 4.2-1.1 6.1 0l29.101 17.101c4.6 2.699 10.1-1.4 8.899-6.601l-7.8-32.399c-.5-2.2.2-4.4 1.9-5.9l26.3-23.1c3.8-3.5 1.6-10-3.6-10.5z'/%3e%3c/svg%3e");
}

.emoji-wrapper {
    width: 100%;
    text-align: center;
    height: 100px;
    overflow: hidden;
    position: absolute;
    top: 0;
    left: 0;
}

    .emoji-wrapper:before,
    .emoji-wrapper:after {
        content: "";
        height: 15px;
        width: 100%;
        position: absolute;
        left: 0;
        z-index: 1;
    }

    .emoji-wrapper:before {
        top: 0;
        background: linear-gradient(to bottom, white 0%, white 35%, rgba(255, 255, 255, 0) 100%);
    }

    .emoji-wrapper:after {
        bottom: 0;
        background: linear-gradient(to top, white 0%, white 35%, rgba(255, 255, 255, 0) 100%);
    }

.emoji {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: .3s;
}

    .emoji > svg {
        margin: 15px 0;
        width: 70px;
        height: 70px;
        flex-shrink: 0;
    }

#rating-1:checked ~ .emoji-wrapper > .emoji {
    -webkit-transform: translateY(-100px);
    transform: translateY(-100px);
}

#rating-2:checked ~ .emoji-wrapper > .emoji {
    -webkit-transform: translateY(-200px);
    transform: translateY(-200px);
}

#rating-3:checked ~ .emoji-wrapper > .emoji {
    -webkit-transform: translateY(-300px);
    transform: translateY(-300px);
}

#rating-4:checked ~ .emoji-wrapper > .emoji {
    -webkit-transform: translateY(-400px);
    transform: translateY(-400px);
}

#rating-5:checked ~ .emoji-wrapper > .emoji {
    -webkit-transform: translateY(-500px);
    transform: translateY(-500px);
}


<hr style=" border:solid; width:100px; height:1px;" color=#000000 size=1">

2.这里是html

<div class="rating">
            <input type="radio" name="rating" id="rating-5">
            <label for="rating-5" id="star5"></label>
            <input type="radio" name="rating" id="rating-4">
            <label for="rating-4" id="star4"></label>
            <input type="radio" name="rating" id="rating-3">
            <label for="rating-3" id="star3"></label>
            <input type="radio" name="rating" id="rating-2">
            <label for="rating-2" id="star2"></label>
            <input type="radio" name="rating" id="rating-1">
            <label for="rating-1" id="star1"></label>
        </div>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值