帝王谷资源网 Design By www.wdxyy.com
先来看一下CSS绘制五角星的基本方法:
- #star-five {
- margin: 50px 0;
- position: relative;
- display: block;
- color: red;
- width: 0px;
- height: 0px;
- border-right: 100px solid transparent;
- border-bottom: 70px solid red;
- border-left: 100px solid transparent;
- -moz-transform: rotate(35deg);
- -webkit-transform: rotate(35deg);
- -ms-transform: rotate(35deg);
- -o-transform: rotate(35deg);
- }
- #star-five:before {
- border-bottom: 80px solid red;
- border-left: 30px solid transparent;
- border-right: 30px solid transparent;
- position: absolute;
- height: 0;
- width: 0;
- top: -45px;
- left: -65px;
- display: block;
- content: "";
- -webkit-transform: rotate(-35deg);
- -moz-transform: rotate(-35deg);
- -ms-transform: rotate(-35deg);
- -o-transform: rotate(-35deg);
- }
- #star-five:after {
- position: absolute;
- display: block;
- color: red;
- top: 3px;
- left: -105px;
- width: 0px;
- height: 0px;
- border-right: 100px solid transparent;
- border-bottom: 70px solid red;
- border-left: 100px solid transparent;
- -webkit-transform: rotate(-70deg);
- -moz-transform: rotate(-70deg);
- -ms-transform: rotate(-70deg);
- -o-transform: rotate(-70deg);
- content: "";
- }
有了这个基础,基本上星级评分的效果就容易实现了:
下图是Demo中会用到的图,可右键另存
HTML Code
- <ul class="rating nostar">
- <li class="one"><a href="#" title="1 Star">1</a>
- </li>
- <li class="two"><a href="#" title="2 Stars">2</a>
- </li>
- <li class="three"><a href="#" title="3 Stars">3</a>
- </li>
- <li class="four"><a href="#" title="4 Stars">4</a>
- </li>
- <li class="five"><a href="#" title="5 Stars">5</a>
- </li>
- </ul>
CSS Code
- .rating {
- width: 124px;
- height: 19px;
- margin: 0 0 20px 0;
- padding: 0;
- list-style: none;
- clear: both;
- position: relative;
- background: url(http://www.zjgsq.com/wp-content/uploads/2014/09/stars.png) no-repeat 0 0;
- }
- .nostar {
- background-position: 0 0
- }
- .onestar {
- background-position: 0 -19px
- }
- .twostar {
- background-position: 0 -38px
- }
- .threestar {
- background-position: 0 -57px
- }
- .fourstar {
- background-position: 0 -76px
- }
- .fivestar {
- background-position: 0 -95px
- }
- ul.rating li {
- cursor: pointer;
- float: left;
- text-indent: -999em;
- }
- ul.rating li a {
- position: absolute;
- left: 0;
- top: 0;
- width: 25px;
- height: 19px;
- text-decoration: none;
- z-index: 200;
- }
- ul.rating li.one a {
- left: 0
- }
- ul.rating li.two a {
- left: 25px;
- }
- ul.rating li.three a {
- left: 50px;
- }
- ul.rating li.four a {
- left: 75px;
- }
- ul.rating li.five a {
- left: 100px;
- }
- ul.rating li a:hover {
- z-index: 2;
- width: 125px;
- height: 19px;
- overflow: hidden;
- left: 0;
- background: url(http://www.zjgsq.com/wp-content/uploads/2014/09/stars.png) no-repeat 0 0
- }
- ul.rating li.one a:hover {
- background-position: 0 -19px;
- }
- ul.rating li.two a:hover {
- background-position: 0 -38px;
- }
- ul.rating li.three a:hover {
- background-position: 0 -57px
- }
- ul.rating li.four a:hover {
- background-position: 0 -76px
- }
- ul.rating li.five a:hover {
- background-position: 0 -95px
- }
这样就基本实现了鼠标hover显示对应的星级,后面再增加点JS来实现click效果就可以啦
Demo
标签:
CSS,星级评分
帝王谷资源网 Design By www.wdxyy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
帝王谷资源网 Design By www.wdxyy.com
暂无评论...
更新日志
2024年10月07日
2024年10月07日
- 群星《前途海量 电影原声专辑》[FLAC/分轨][227.78MB]
- 张信哲.1992-知道新曲与精丫巨石】【WAV+CUE】
- 王翠玲.1995-ANGEL【新艺宝】【WAV+CUE】
- 景冈山.1996-我的眼里只有你【大地唱片】【WAV+CUE】
- 群星《八戒 电影原声带》[320K/MP3][188.97MB]
- 群星《我的阿勒泰 影视原声带》[320K/MP3][139.47MB]
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[320K/MP3][148.91MB]
- 刘雅丽.2001-丽花皇后·EMI精选王【EMI百代】【FLAC分轨】
- 齐秦.1994-黄金十年1981-1990CHINA.TOUR.LIVE精丫上华】【WAV+CUE】
- 群星.2008-本色·百代音乐人创作专辑【EMI百代】【WAV+CUE】
- 群星.2001-同步过冬AVCD【环球】【WAV+CUE】
- 群星.2020-同步过冬2020冀待晴空【环球】【WAV+CUE】
- 沈雁.1986-四季(2012梦田复刻版)【白云唱片】【WAV+CUE】
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[FLAC/分轨][257.88MB]
- 《国语老歌 怀旧篇 3CD》[WAV/分轨][1.6GB]