Display Star in Front End based on rating

前端 未结 5 1620
名媛妹妹
名媛妹妹 2021-01-29 09:49

I have created a field in backend where using radio button am selecting the rating of product as 1 star, 2 star, 3 star, 4 star and 5 Star

In front end when displaying s

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-29 10:14

    Use below condition in each input:

    prodDet->v_child_safety=="1 star"){?>checked="checked"

    and use disabled to disable all input so that no one can change value if you just want to display rating.

    div.stars {
      width: 270px;
      display: inline-block;
    }
    
    input.star { display: none; }
    
    label.star {
      float: right;
      padding: 10px;
      font-size: 36px;
      color: #444;
      transition: all .2s;
    }
    
    input.star:checked ~ label.star:before {
      content: '\2605';
      color: #FD4;
      transition: all .25s;
    }
    
    input.star-5:checked ~ label.star:before {
      color: #FE7;
      text-shadow: 0 0 20px #952;
    }
    
    input.star-1:checked ~ label.star:before { color: #F62; }
    
    label.star:hover { transform: rotate(-15deg) scale(1.3); }
    
    label.star:before {
      content: '\2605';
    }

    Expert Rating

提交回复
热议问题