分值显示

通过五个五角星展示分数的效果,能实现根据长度显示星星内部的效果,比如只有2.1个星这样的效果,如图:



 

 

代码如下:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>无标题文档</title>
</head>
<body>
<style type="text/css">
.box215{width:215px;border-bottom:1px solid #e5e5e5;padding-bottom:10px;margin-left: 20px;}
.titPf{height:40px;line-height:40px;}
.scroCol{height:29px;padding-bottom:10px;}
.staL{float:left;display:inline;margin:10px 7px 0 0;background:#b4b3b1;width:99px;height:14px;}
.yelloS{background:#f2d03d;width:1px;height:14px;}
.scoR{float:left;display:inline;margin:5px 0 0 0;}
.scoB{font-family:Arial;font-size:18px;color:#cc0001;}
.scoP{color:#999999;}
</style>
<div class="box215">
<div class="titPf f14">打分:</div>
<div class="scroCol clearfix">
<div class="staL">
<div class="yelloS" id="score"><img src="http://dl2.iteye.com/upload/attachment/0100/8849/e3593dfa-6560-3008-9dbf-e052bc6fafb3.gif" width="99" height="14" /></div>
</div>
<div class="scoR"><em class="scoB" id="fen">4.8</em><em class="scoP"></em></div>
</div>


<script type="text/javascript">
var n = 2;//获取星星之间的间隔,比如会有3颗星星,中间的间隔就是2,因为星星之间是有间隙的,所以需要加上间隔的长度
var len = 6*n + 36;
document.getElementById("score").style.width = len + "px";
</script>
</div>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这里给出一个基于Arduino的DS1302时钟模块的代码示例,可以将时间信息显示在LCD上并实时更新: ``` #include <LiquidCrystal.h> #include <DS1302.h> // 初始化DS1302模块 DS1302 rtc(2, 3, 4); // 初始化LCD模块 LiquidCrystal lcd(8, 9, 4, 5, 6, 7); void setup() { // 初始化LCD lcd.begin(16, 2); // 初始化DS1302时钟模块 rtc.halt(false); rtc.writeProtect(false); rtc.setDateTime(DS1302::DateTime(__DATE__, __TIME__)); } void loop() { // 获取当前时间 DS1302::DateTime now = rtc.getDateTime(); // 将时间信息显示在LCD上 lcd.setCursor(0, 0); lcd.print("20"); lcd.print(now.year); lcd.print("/"); lcd.print(now.month); lcd.print("/"); lcd.print(now.day); lcd.print(" "); lcd.print(getWeekday(now)); lcd.setCursor(0, 1); lcd.print(now.hour); lcd.print(":"); if (now.minute < 10) { lcd.print("0"); } lcd.print(now.minute); lcd.print(":"); if (now.second < 10) { lcd.print("0"); } lcd.print(now.second); // 等待1秒钟 delay(1000); } // 获取星期几的字符串表示 String getWeekday(DS1302::DateTime now) { switch (now.dayOfWeek) { case 1: return "Mon"; case 2: return "Tue"; case 3: return "Wed"; case 4: return "Thu"; case 5: return "Fri"; case 6: return "Sat"; case 7: return "Sun"; default: return ""; } } ``` 该代码中使用了LiquidCrystal库和DS1302库来控制LCD和DS1302时钟模块。在setup函数中,我们初始化了LCD和DS1302时钟模块,并将当前时间设置为编译时的时间。在loop函数中,我们不断获取当前时间并将时间信息显示在LCD上,然后等待1秒钟后再重复这个过程。为了方便显示,我们将日期和星期的字符串表示合并到了一起。getWeekday函数根据DS1302库返回的星期几数字返回对应的字符串表示。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值