小米官网仿造(三)--jQuery(抢购部分)

2024-02-26 20:59

本文主要是介绍小米官网仿造(三)--jQuery(抢购部分),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

接上~

效果图:是通过移动ul的移动来进行,但是倒计时没有进行事实的改变~ 最后的时候能够进行禁用箭头的点击效果
在这里插入图片描述
在这里插入图片描述

html代码

  <div class="recommend"><!-- reconmend部分开始 --><div class="reconmend w clearfix"><ul class="reconmendUl"><li class="reconmendBar"><ul><li><a href="#"><div class="iconfont">&#xe501;</div><div>选购手机</div></a></li><li><div class="Barcolor"></div></li><li><a href="#"><div class="iconfont">&#xe536;</div><div>企业团购</div></a></li><li><div class="Barcolor"></div></li><li><a href="#"><div class="iconfont">&#xe611;</div><div>F码通道</div></a></li><li><div class="Barcolor" style="background:#5f5750"></div></li><li><a href="#"><div class="iconfont">&#xe50a;</div><div>米粉卡</div></a></li><li><div class="Barcolor"></div></li><li><a href="#"><div class="iconfont">&#xe658;</div><div>以旧换新</div></a></li><li><div class="Barcolor"></div></li><li><a href="#"><div class="iconfont">&#xe61a;</div><div>话费充值</div></a></li></ul></li><li><a href="#"><img src="../upload/xmad_15381015124677_QcEGp.jpg" alt="" /></a></li><li><a href="#"><img src="../upload/xmad_15410029988871_TdzPQ.jpg" alt="" /></a></li><li><a href="#"><img src="../upload/xmad_15410599445473_Ivjsb.jpg" alt="" /></a></li></ul></div><!-- reconmend部分结束 --><!-- 抢购部分开始 --><div class="purchase w"><div class="purTop clearfix"><span class="fl">小米抢购</span><div class="arrow fr"><button id="purArrowF" disabled="disabled">&lt;</button><button id="purArrowR">&gt;</button></div></div><div class="purBot clearfix"><div class="purL fl"><div class="chang">10:00场</div><div class="putpic"><img src="../upload/flashpurchase.png " alt=" " /></div><div class="juli">距离结束还有</div><div class="time clearfix"><ul><li id="shi">01</li><li>:</li><li id="fen">31</li><li>:</li><li id="miao">51</li></ul></div></div><div class="purR fr"><ul class="clearfix " id="purR-pro"></ul></div></div><div><a href="#"><img src="../upload/xmad_15464805744595_gfbXL.jpg " alt=" " style="width: 1226px;margin-top: 42px; margin-bottom: 42px" /></a></div><script src="../js/qianggou.js"></script></div><!-- 抢购部分结束 --></div>

css

/* reconmend样式开始 */
.reconmend {height: 170px;margin-top: 40px;margin-bottom: 27px;
}.reconmend .reconmendUl>li {float: left;
}.reconmend .reconmendUl .reconmendBar {width: 233px;height: 170px;background-color: #5f5750;overflow: hidden;
}.reconmend ul .reconmendBar ul {margin-left: 4px;
}.reconmend ul .reconmendBar li {float: left;margin-left: 5px;
}.reconmend ul .reconmendBar li:nth-child(even) {padding-top: 9px;height: 66px;;
}.reconmend ul .reconmendBar li:nth-child(even) div {width: 1px;height: 70px;background-color: #665e57;
}.reconmend ul .reconmendBar li:nth-child(odd) {padding-top: 19px;padding-bottom: 19px;text-align: center;width: 64px;height: 47px;border-bottom: 1px solid #665e57;
}.reconmend ul .reconmendBar li a {color: #fff;
}.reconmend .reconmendUl>li:nth-child(2) {margin-left: 14px;margin-right: 14px;
}.reconmend .reconmendUl>li:nth-child(3) {margin-right: 14px;
}.reconmend .reconmendUl>li:nth-child(1) li {float: left;/* width: 79px; */
}.reconmend .reconmendUl>li img {width: 316px;height: 170px;
}
/* reconmend样式结束 */
/* 抢购部分样式开始 */
.purTop {padding-top: 18px;
}.purTop span {margin-bottom: 18px;font-size: 22px;
}.purTop .arrow {padding-top: 8px;
}.purTop .arrow button {width: 35px;height: 23px;
}.purBot .purL {padding-top: 60px;/* padding-bottom: 48px; */width: 234px;text-align: center;height: 278px;background-color: #f1eded;border-top: 1px solid #e53935;
}.purBot .purL .chang {font-size: 18px;margin-bottom: 34px;
}.purBot .purL .juli {font-size: 14px;margin-top: 36px;
}.purBot .time ul {list-style: none;/*设定宽度*/width: 168px;margin-top: 33px;margin-left: 33px;
}.purBot .time ul li {float: left;
}.purBot .time ul li:nth-child(odd) {width: 46px;background-color: #605751;height: 46px;text-align: center;line-height: 46px;font-size: 18px;color: #fff;
}.purBot .time ul li:nth-child(even) {font-size: 4px;margin: 0 6px;margin-top: 17px;
}.purBot .purR {overflow: hidden;width: 992px;height: 339px;
}.purBot .purR ul {position: relative;width: 400%;
}.purBot .purR li {float: left;padding-top: 40px;margin-left: 14px;width: 234px;height: 299px;text-align: center;background-color: #fff;
}.purBot .purR li a img {margin-bottom: 33px;height: 158px;
}.purBot .purR .purPrice {font-size: 12px;color: #fa7d09;
}.purBot .purR li a>a {font-size: 12px;color: #822020;
}.purBot .purR li a span:last-child {font-size: 12px;color: #adadad;
}
/* 抢购部分样式结束 */

jq:

$(function() {// 抢购部分开始// 倒计时部分var shiBox = $('#shi');var fenBox = $('#fen');var miaoBox = $('#miao');var hh = parseInt(shiBox.text())var mm = parseInt(fenBox.text())var ss = parseInt(miaoBox.text())var time = setInterval(function() {ss--;if (ss < 0) {ss = 59;mm--;}if (mm < 0) {mm = 59;hh--;}if (hh < 0) {hh = 0}var sss = ss < 10 ? '0' + ss : ss;var mmm = mm < 10 ? '0' + mm : mm;var hhh = hh < 10 ? '0' + hh : hh;shiBox.text(hhh)fenBox.text(mmm)miaoBox.text(sss)if (hh === 0 && mm === 0 && ss === 0) {clearInterval(timer);miaoBox.innerText = '了';fenBox.innerText = '束';shiBox.innerText = '结';}}, 1000)var purTemp = '';var purRArr = [{img: '../upload/05c5b22c8ae030b6c5de7d36114a32e4.jpg',name: '小米米家对讲机1S蓝色',intorduct: '再次出发,陪你轻聊一路',preic: '9.9元',before: '249元'}, {img: '../upload/90553f751c9eb6bda9a2ae7c4bce012b.jpg',name: '小米电视4A 58英寸 黑色',intorduct: '4K HDR,人工智能语音系统',preic: '2499元',before: '2999元'}, {img: '../upload/pms_1516011154.79573723.jpg',name: '小米电视4A 50英寸 黑色',intorduct: '4K HDR,人工智能语音系统',preic: '1899元',before: '2199元'}, {img: '../upload/553e9c2b-0023-e9a7-3bdb-26ec66a4007c.jpg',name: '小米移动电源10000mAh高配',intorduct: '轻薄设计,轻松出行',preic: '139元',before: '1499元'}, {img: '../upload/2e24730eb6fb2963b9b59493a6e5a0c7.jpg',name: '小米移动电源10000mAh高配',intorduct: '轻薄设计,轻松出行',preic: '139元',before: '1499元'}, {img: '../upload/3803a3bc-87b5-9ea8-a917-b753d429d1f4.jpg',name: '小米移动电源10000mAh高配',intorduct: '轻薄设计,轻松出行',preic: '139元',before: '1499元'}, {img: '../upload/761af25d-aebe-7568-dc6d-08e0690d69d2.png',name: '小米移动电源10000mAh高配',intorduct: '轻薄设计,轻松出行',preic: '139元',before: '1499元'}, {img: '../upload/ef88f3b004a4ca83b672896925e3d9fe.jpg',name: '小米移动电源10000mAh高配',intorduct: '轻薄设计,轻松出行',preic: '139元',before: '1499元'}, {img: '../upload/pms_1537842310.77778515.jpg',name: '小米移动电源10000mAh高配',intorduct: '轻薄设计,轻松出行',preic: '139元',before: '1499元'}, {img: '../upload/pms_1538191811.69072723.jpg',name: '小米移动电源10000mAh高配',intorduct: '轻薄设计,轻松出行',preic: '139元',before: '1499元'}, {img: '../upload/xmad_15281923207128_rOfDp.png',name: '小米移动电源10000mAh高配',intorduct: '轻薄设计,轻松出行',preic: '139元',before: '1499元'}, {img: '../upload/xmad_15350951136177_QUuVm.png',name: '小米移动电源10000mAh高配',intorduct: '轻薄设计,轻松出行',preic: '139元',before: '1499元'}]for (var i = 0; i < purRArr.length; i++) {purTemp += '<li>' +'<a href="#">' +'<img src="' + purRArr[i].img + '" alt=""><br/>' +'<a href="#">' + purRArr[i].name + '</a>' +'<div>' + purRArr[i].intorduct + '</div>' +'<span class="purPrice">' + purRArr[i].preic + '</span>' +'<span><del>' + purRArr[i].before + '</del></span>' +'</a>' +' </li>'}$('#purR-pro').html(purTemp);// 随机数函数封装function getrad(n) {return Math.floor(Math.random() * (n + 1))}for (var i = 0; i < purRArr.length; i++) {$('#purR-pro li')[i].style.borderTop = '1px solid rgb(' + getrad(255) + ',' + getrad(255) + ',' + getrad(255) + ')'}var purRNum = 0$('.arrow #purArrowR').on('click', function() {purRNum++;$('#purR-pro').animate({ left: -992 * purRNum }, 1000);if (purRNum == 2) {$('#purArrowR').prop('disabled', true);};$('#purArrowF').prop('disabled', false);})$('.arrow #purArrowF').on('click', function() {if (purRNum <= 1) {$('#purArrowF').prop('disabled', true);};purRNum--;$('#purR-pro').animate({ left: -992 * purRNum }, 1000)$('#purArrowR').prop('disabled', false);})
})

这篇关于小米官网仿造(三)--jQuery(抢购部分)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/750147

相关文章

HTML5中的Microdata与历史记录管理详解

《HTML5中的Microdata与历史记录管理详解》Microdata作为HTML5新增的一个特性,它允许开发者在HTML文档中添加更多的语义信息,以便于搜索引擎和浏览器更好地理解页面内容,本文将探... 目录html5中的Mijscrodata与历史记录管理背景简介html5中的Microdata使用M

html5的响应式布局的方法示例详解

《html5的响应式布局的方法示例详解》:本文主要介绍了HTML5中使用媒体查询和Flexbox进行响应式布局的方法,简要介绍了CSSGrid布局的基础知识和如何实现自动换行的网格布局,详细内容请阅读本文,希望能对你有所帮助... 一 使用媒体查询响应式布局        使用的参数@media这是常用的

HTML5表格语法格式详解

《HTML5表格语法格式详解》在HTML语法中,表格主要通过table、tr和td3个标签构成,本文通过实例代码讲解HTML5表格语法格式,感兴趣的朋友一起看看吧... 目录一、表格1.表格语法格式2.表格属性 3.例子二、不规则表格1.跨行2.跨列3.例子一、表格在html语法中,表格主要通过< tab

Vue3组件中getCurrentInstance()获取App实例,但是返回null的解决方案

《Vue3组件中getCurrentInstance()获取App实例,但是返回null的解决方案》:本文主要介绍Vue3组件中getCurrentInstance()获取App实例,但是返回nu... 目录vue3组件中getCurrentInstajavascriptnce()获取App实例,但是返回n

一文详解如何在Python中从字符串中提取部分内容

《一文详解如何在Python中从字符串中提取部分内容》:本文主要介绍如何在Python中从字符串中提取部分内容的相关资料,包括使用正则表达式、Pyparsing库、AST(抽象语法树)、字符串操作... 目录前言解决方案方法一:使用正则表达式方法二:使用 Pyparsing方法三:使用 AST方法四:使用字

JS+HTML实现在线图片水印添加工具

《JS+HTML实现在线图片水印添加工具》在社交媒体和内容创作日益频繁的今天,如何保护原创内容、展示品牌身份成了一个不得不面对的问题,本文将实现一个完全基于HTML+CSS构建的现代化图片水印在线工具... 目录概述功能亮点使用方法技术解析延伸思考运行效果项目源码下载总结概述在社交媒体和内容创作日益频繁的

前端CSS Grid 布局示例详解

《前端CSSGrid布局示例详解》CSSGrid是一种二维布局系统,可以同时控制行和列,相比Flex(一维布局),更适合用在整体页面布局或复杂模块结构中,:本文主要介绍前端CSSGri... 目录css Grid 布局详解(通俗易懂版)一、概述二、基础概念三、创建 Grid 容器四、定义网格行和列五、设置行

前端下载文件时如何后端返回的文件流一些常见方法

《前端下载文件时如何后端返回的文件流一些常见方法》:本文主要介绍前端下载文件时如何后端返回的文件流一些常见方法,包括使用Blob和URL.createObjectURL创建下载链接,以及处理带有C... 目录1. 使用 Blob 和 URL.createObjectURL 创建下载链接例子:使用 Blob

Vuex Actions多参数传递的解决方案

《VuexActions多参数传递的解决方案》在Vuex中,actions的设计默认只支持单个参数传递,这有时会限制我们的使用场景,下面我将详细介绍几种处理多参数传递的解决方案,从基础到高级,... 目录一、对象封装法(推荐)二、参数解构法三、柯里化函数法四、Payload 工厂函数五、TypeScript

Vue3使用router,params传参为空问题

《Vue3使用router,params传参为空问题》:本文主要介绍Vue3使用router,params传参为空问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录vue3使用China编程router,params传参为空1.使用query方式传参2.使用 Histo