小米官网仿造(三)--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

相关文章

CSS3中使用flex和grid实现等高元素布局的示例代码

《CSS3中使用flex和grid实现等高元素布局的示例代码》:本文主要介绍了使用CSS3中的Flexbox和Grid布局实现等高元素布局的方法,通过简单的两列实现、每行放置3列以及全部代码的展示,展示了这两种布局方式的实现细节和效果,详细内容请阅读本文,希望能对你有所帮助... 过往的实现方法是使用浮动加

css渐变色背景|<gradient示例详解

《css渐变色背景|<gradient示例详解》CSS渐变是一种从一种颜色平滑过渡到另一种颜色的效果,可以作为元素的背景,它包括线性渐变、径向渐变和锥形渐变,本文介绍css渐变色背景|<gradien... 使用渐变色作为背景可以直接将渐China编程变色用作元素的背景,可以看做是一种特殊的背景图片。(是作为背

CSS自定义浏览器滚动条样式完整代码

《CSS自定义浏览器滚动条样式完整代码》:本文主要介绍了如何使用CSS自定义浏览器滚动条的样式,包括隐藏滚动条的角落、设置滚动条的基本样式、轨道样式和滑块样式,并提供了完整的CSS代码示例,通过这些技巧,你可以为你的网站添加个性化的滚动条样式,从而提升用户体验,详细内容请阅读本文,希望能对你有所帮助...

css实现图片旋转功能

《css实现图片旋转功能》:本文主要介绍了四种CSS变换效果:图片旋转90度、水平翻转、垂直翻转,并附带了相应的代码示例,详细内容请阅读本文,希望能对你有所帮助... 一 css实现图片旋转90度.icon{ -moz-transform:rotate(-90deg); -webkit-transfo

vue基于ElementUI动态设置表格高度的3种方法

《vue基于ElementUI动态设置表格高度的3种方法》ElementUI+vue动态设置表格高度的几种方法,抛砖引玉,还有其它方法动态设置表格高度,大家可以开动脑筋... 方法一、css + js的形式这个方法需要在表格外层设置一个div,原理是将表格的高度设置成外层div的高度,所以外层的div需要

Vue项目中Element UI组件未注册的问题原因及解决方法

《Vue项目中ElementUI组件未注册的问题原因及解决方法》在Vue项目中使用ElementUI组件库时,开发者可能会遇到一些常见问题,例如组件未正确注册导致的警告或错误,本文将详细探讨这些问题... 目录引言一、问题背景1.1 错误信息分析1.2 问题原因二、解决方法2.1 全局引入 Element

详解如何在React中执行条件渲染

《详解如何在React中执行条件渲染》在现代Web开发中,React作为一种流行的JavaScript库,为开发者提供了一种高效构建用户界面的方式,条件渲染是React中的一个关键概念,本文将深入探讨... 目录引言什么是条件渲染?基础示例使用逻辑与运算符(&&)使用条件语句列表中的条件渲染总结引言在现代

详解Vue如何使用xlsx库导出Excel文件

《详解Vue如何使用xlsx库导出Excel文件》第三方库xlsx提供了强大的功能来处理Excel文件,它可以简化导出Excel文件这个过程,本文将为大家详细介绍一下它的具体使用,需要的小伙伴可以了解... 目录1. 安装依赖2. 创建vue组件3. 解释代码在Vue.js项目中导出Excel文件,使用第三

Java实现Excel与HTML互转

《Java实现Excel与HTML互转》Excel是一种电子表格格式,而HTM则是一种用于创建网页的标记语言,虽然两者在用途上存在差异,但有时我们需要将数据从一种格式转换为另一种格式,下面我们就来看看... Excel是一种电子表格格式,广泛用于数据处理和分析,而HTM则是一种用于创建网页的标记语言。虽然两

vue解决子组件样式覆盖问题scoped deep

《vue解决子组件样式覆盖问题scopeddeep》文章主要介绍了在Vue项目中处理全局样式和局部样式的方法,包括使用scoped属性和深度选择器(/deep/)来覆盖子组件的样式,作者建议所有组件... 目录前言scoped分析deep分析使用总结所有组件必须加scoped父组件覆盖子组件使用deep前言