第1关:限时秒杀效果图片渲染

图1如下 链接为https://data.educoder.net/api/attachments/2089667

图2如下 链接为https://data.educoder.net/api/attachments/2089666


编程要求

根据提示,在右侧编辑器补充代码。 要求使用指定的两张图片已经给出图片对应的url 要求设置图片的宽度为702px 图片高度378px 背景图url(https://data.educoder.net/api/attachments/2089667)

 <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>限时秒杀</title>
<style type="text/css">
/*全局控制*/
body{font-size:20px; color:#fff; font-family: microsoft yahei,arial;}
/*清除浏览器默认样式*/
img{list-style:none; outline:none;}
.img-box{
position:relative;
/* ********* Begin ********* */
width:702px;
height:378px;
background:url(https://www.educoder.net/api/attachments/2089667);
/* ********* End ********* */
margin:0 auto;
}
.img-box span{
position:relative;
text-align:center;
line-height:26px;
margin:4px 0 0;
}
.img-box #hour{
left:50.6%;
top:68.35%
}
.img-box #munite{
left:55.2%;
top:68.35%;
}
.img-box #second{
left:59.6%;
top:68.35%;
}
#bot-box{
position:absolute;
z-index:1;
top:250px;
display:none;
width:702px;
height:51px;
line-height:40px;
text-align:center;
color:#666;
font-size:28px;
}
</style>
</head>
<body>
<div class="img-box">                         <!--设置秒杀时间块--><span id="hour"></span><span id="munite"></span><span id="second"></span><div id="bot-box"></div>                <!--设置限时秒杀结束块-->
</div>
</body>
</html>

第2关:限时秒杀效果javascript训练

编程要求

根据提示,在右侧编辑器补充代码。 需要向时分秒对应的标签中插入时间值 注:同学们在练习时注意修改endtime 当endtime 与当前时间距离不到24小时 限时秒杀动态效果最好 如果同学们不修改endtime 会静态显示秒杀结束画面

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>限时秒杀</title>
<style type="text/css">
/*全局控制*/
body{font-size:20px; color:#fff; font-family: microsoft yahei,arial;}
/*清除浏览器默认样式*/
img{list-style:none; outline:none;}
.img-box{
position:relative;
background:url(https://www.educoder.net/api/attachments/2089667);
width:702px;
height:378px;
margin:0 auto;
}
.img-box span{
position:relative;
text-align:center;
line-height:26px;
margin:4px 0 0;
}
.img-box #hour{
left:50.6%;
top:68.35%
}
.img-box #munite{
left:55.2%;
top:68.35%;
}
.img-box #second{
left:59.6%;
top:68.35%;
}
#bot-box{
position:absolute;
z-index:1;
top:250px;
display:none;
width:702px;
height:51px;
line-height:40px;
text-align:center;
color:#666;
font-size:28px;
}
</style>
</head>
<body onload="fresh()">
<div class="img-box">                         <!--设置秒杀时间块--><span id="hour"></span><span id="munite"></span><span id="second"></span><div id="bot-box"></div>                <!--设置限时秒杀结束块-->
</div>
<script type="text/javascript">
function fresh()
{//设置秒杀结束时间,同学们设置相对时间为24小时以内 javascript加载效果最佳 // 如果同学们不修改此处时间会导致判断结果为秒杀结束var endtime=new Date("2022/6/18,01:01:01");//获取当前时间 当前时间变量为var nowtime/* *************start***************** */var nowtime = new Date();/* *************End***************** *///计算剩余秒杀时间,单位为秒var leftsecond=parseInt((endtime.getTime()-nowtime.getTime())/1000);h=parseInt(leftsecond/3600);//计算剩余小时m=parseInt((leftsecond/60)%60); //计算剩余分钟s=parseInt(leftsecond%60); //计算剩余秒if(h<10) h= "0"+h;if(m<10 && m>=0) m= "0"+m; else if(m<0) m="00";if(s<10 && s>=0) s= "0"+s; else if(s<0) s="00";//向html中插入时分秒 使用id:hour munite second/* *************start***************** */document.getElementById("hour").innerHTML=h;document.getElementById("munite").innerHTML=m;document.getElementById("second").innerHTML=s;/* *************End***************** *///判断秒杀是否结束,结束则输出相应提示信息if(leftsecond<=0){document.getElementById("bot-box").style.display="block";document.getElementById("bot-box").style.background="url(https://www.educoder.net/api/attachments/2089666) no-repeat";//向html中插入”秒杀已结束“提醒/* *************start***************** */if(leftsecond<=0){document.getElementById("bot-box").style.display="block";document.getElementById("bot-box").style.background="url(https://www.educoder.net/api/attachments/2089666) no-repeat";document.getElementById("bot-box").innerHTML="秒杀已结束";}/* *************End***************** */clearInterval(sh);}
}
//设计倒计时
var sh=setInterval(fresh,1000);
</script>
</body>
</html>

Web综合应用案例-限时秒杀效果的制作相关推荐

  1. educoder头歌Web实训 web课——综合应用案例:限时秒杀效果的制作

    educoder头歌Web实训 太原理工web课--综合应用案例:动态焦点图页面的制作[全网更新最快]_玛卡巴卡的博客-CSDN博客 第1关:限时秒杀效果图片渲染 [TOC] 图1如下 链接为htt ...

  2. web综合 限时秒杀效果的制作

    第1关:限时秒杀效果图片渲染 TOC] 图1如下 链接为https://www.educoder.net/api/attachments/2089667 图2如下 链接为https://www.edu ...

  3. web前端-综合应用案例-简历表页面的制作-educoder

    第1关:简历表页面的结构设计 <!doctype html> <html> <head> <meta charset="utf-8"> ...

  4. 盘点三个JavaScript案例——实现限时秒杀、定时跳转、改变盒子大小

    前言 今天来给大家盘点三个JavaScript案例,分别是实现限时秒杀.定时跳转.改变盒子大小案例,一起来看看吧! 一.实现限时秒杀案例 1.在淘宝网中,商家为了促销经常搞一些活动,例如限时秒杀是常见 ...

  5. educoder头歌Web实训 web课——综合应用案例:动态焦点图页面的制作

    educoder头歌Web实训 太原理工web课--综合应用案例:拼图页面的制作[全网更新最快]_玛卡巴卡的博客-CSDN博客 第1关:动态焦点图页面的样式设计 任务描述 本关任务: 完成动态焦点图 ...

  6. 限时秒杀的整体代码在html中,限时秒杀.html

    限时秒杀 .box{margin:0 auto;position:relative;background:url(images/flash_sale.png);width:702px;height:3 ...

  7. 【JavaScript实训】-- 限时秒杀

    这道题是我在上js课程的时候,老师临时给我们出的一道题,虽然说这种小练习之前也要写过相关代码,但好像把它综合到一起,我就蒙圈了,哎~ 实现页面: 目录 一.实现步骤详解: 1.设置秒杀结束时间 2.声 ...

  8. JavaScript限时秒杀

    <!DOCTYPE html> <html><head><meta charset="utf-8"><title>< ...

  9. 杨老师课堂之JavaScript定时器_农夫山泉限时秒杀案例

    预览效果图: 使用到的知识点: 定时器 setInterval(函数,毫秒):在指定的毫秒数后调用函数或执行一段代码 取消定时器 clearInterval:取消由setInterval设置的定时器 ...

最新文章

  1. Android studio 编译器导入一个背景图片
  2. 一人一天发两篇Science,视频揭秘:植物如何在与病菌的斗争中取胜?
  3. hdoj1087 (DP--LIS)
  4. 评分卡模型剖析之一(woe、IV、ROC、信息熵)
  5. Ambari 2.6.0 HDP 2.6.3集群搭建
  6. c语言结构体指针初始化
  7. 切图后用ie6浏览时切片间有空隙
  8. linux监听端口无响应,linux – tomcat运行,但是8080端口没有响应
  9. java计算每个元素出现的百分比_java – 计算百分比“x / y * 100”总是导致0?
  10. 深度学习之激活函数详解
  11. Eclipse的环境配置
  12. ANSYS CFD网格划分笔记1
  13. ArcGis软件出图时修改色带上的刻度并导出色带
  14. matlab 行 读取文件 跳过_matlab-Textscan在行首跳过所需的空白
  15. kali使用Aircrack-ng破解WEP、WPA的WIFI密码教程
  16. 对于一个类似VBF文件中有ASCII+二进制俩种编码方式的文件的读取
  17. android平台支付宝快捷支付
  18. 水泥路面、桥梁基建、隧道裂痕裂缝检测数据集
  19. 工具中的文件夹选项不见了!
  20. armv8 mmu The Access flag and The dirty state

热门文章

  1. Unity靠近后开关门的效果实现
  2. 开发app需要什么技术?手机app制作方式、价格及性能盘点
  3. 一图了解英特尔® 超能云终端的12个问题!
  4. 清华大学 陈晨 计算机,TNet基于树型结构集群工具软件通信协议.PDF
  5. 计算机图灵,什么叫做图灵计算机?
  6. 吉林大学数据库系统概念2015年期末试题自做答案
  7. 运行单机游戏时,缺少D3DCompiler_43.dll
  8. python 京东 抢券_Python写一个京东抢券脚本
  9. C++中的对齐方式及sizeof小结
  10. 图像类找工作面试题(二)——常见问题大总结