Integrating CSS star rating into an HTML form

后端 未结 6 855
梦如初夏
梦如初夏 2020-12-02 15:09

I\'ve seen a tutorial online - http://www.htmldrive.net/items/show/402/CSS-Star-Rating-System - for making a CSS star rating system.

On the page they have this code

6条回答
  •  囚心锁ツ
    2020-12-02 15:43

    Here is how to integrate CSS star rating into an HTML form without using javascript (only html and css):

    CSS:

    .txt-center {
        text-align: center;
    }
    .hide {
        display: none;
    }
    
    .clear {
        float: none;
        clear: both;
    }
    
    .rating {
        width: 90px;
        unicode-bidi: bidi-override;
        direction: rtl;
        text-align: center;
        position: relative;
    }
    
    .rating > label {
        float: right;
        display: inline;
        padding: 0;
        margin: 0;
        position: relative;
        width: 1.1em;
        cursor: pointer;
        color: #000;
    }
    
    .rating > label:hover,
    .rating > label:hover ~ label,
    .rating > input.radio-btn:checked ~ label {
        color: transparent;
    }
    
    .rating > label:hover:before,
    .rating > label:hover ~ label:before,
    .rating > input.radio-btn:checked ~ label:before,
    .rating > input.radio-btn:checked ~ label:before {
        content: "\2605";
        position: absolute;
        left: 0;
        color: #FFD700;
    }
    

    HTML:

    Please check the demo

提交回复
热议问题