星级评分系统html [英] Star-Rating System html

查看:130
本文介绍了星级评分系统html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编写留言簿,我想创建一个星级评分系统.但是我被卡住了!我只是无法固定星星,以使它们在单击时保持黄色(凝胶).

I'm currently working on a Guestbook and I would like to create a Star-Rating System. But I'm stuck! I just can't fix the stars so that they stay yellow(gelb) when I click on them.

到目前为止,这是我的代码:

This is my code so far:

  <div class="rating">
        <p id="rating-paragraph">Rate</p>
        <img id="stern1" src="pictures/durchsichtig.png"  onmouseover="stern1.src='pictures/gelb.png'" onmouseout="stern1.src='pictures/durchsichtig.png'" alt="error"> <?php ?>
        <img id="stern2" src="pictures/durchsichtig.png"  onmouseover="stern1.src='pictures/gelb.png'; this.src='pictures/gelb.png'" onmouseout="stern1.src='pictures/durchsichtig.png'; this.src='pictures/durchsichtig.png'" alt="error">
        <img id="stern3" src="pictures/durchsichtig.png"  onmouseover="stern1.src='pictures/gelb.png'; stern2.src='pictures/gelb.png'; this.src='pictures/gelb.png' " onmouseout="stern1.src='pictures/durchsichtig.png';stern2.src='pictures/durchsichtig.png'; this.src='pictures/durchsichtig.png' " alt="error">
        <img id="stern4" src="pictures/durchsichtig.png"  onmouseover="stern1.src='pictures/gelb.png'; stern2.src='pictures/gelb.png'; stern3.src='pictures/gelb.png'; this.src='pictures/gelb.png' " onmouseout="stern1.src='pictures/durchsichtig.png';stern2.src='pictures/durchsichtig.png'; stern3.src='pictures/durchsichtig.png';this.src='pictures/durchsichtig.png' " alt="error">
        <img id="stern5" src="pictures/durchsichtig.png"  onmouseover="stern1.src='pictures/gelb.png'; stern2.src='pictures/gelb.png'; stern3.src='pictures/gelb.png'; stern4.src='pictures/gelb.png'; this.src='pictures/gelb.png' " onmouseout="stern1.src='pictures/durchsichtig.png';stern2.src='pictures/durchsichtig.png'; stern3.src='pictures/durchsichtig.png';stern4.src='pictures/durchsichtig.png'; this.src='pictures/durchsichtig.png' " alt="error">
    </div>

和CSS:

#stern1:hover, #stern2:hover, #stern3:hover, #stern4:hover, #stern5:hover{
    cursor: pointer;
}

感谢您的宝贵时间,也许还需要一些帮助或建议:)

Thanks for your time and maybe for some help or advice :)

推荐答案

没有任何图像的纯CSS + HTML评级方法(仅适用于unicode charecter)

Pure CSS+HTML rating method without any images (works only with unicode charecter)

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';
}

<div class="stars">
  <form action="">
    <input class="star star-5" id="star-5" type="radio" name="star"/>
    <label class="star star-5" for="star-5"></label>
    <input class="star star-4" id="star-4" type="radio" name="star"/>
    <label class="star star-4" for="star-4"></label>
    <input class="star star-3" id="star-3" type="radio" name="star"/>
    <label class="star star-3" for="star-3"></label>
    <input class="star star-2" id="star-2" type="radio" name="star"/>
    <label class="star star-2" for="star-2"></label>
    <input class="star star-1" id="star-1" type="radio" name="star"/>
    <label class="star star-1" for="star-1"></label>
  </form>
</div>

这篇关于星级评分系统html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆