赞
踩
采用的架构为html+css+js
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小米闪购-小米商城</title> <!-- 引用图标 --> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> <!-- 连接css样式 --> <link rel="stylesheet" href="css\style.css"> <link rel="stylesheet" href="css/iconfont.css"> </head> <body> <div class="header"> <div class="container"> <div class="header_nav"> <a href=""> 小米商城 </a><span>|</span> <a href=""> MIUI </a><span>|</span> <a href=""> IoT </a><span>|</span> <a href=""> 云服务 </a><span>|</span> <a href=""> 天星数科 </a><span>|</span> <a href=""> 有品 </a><span>|</span> <a href=""> 小爱开放平台 </a><span>|</span> <a href=""> 企业团购 </a><span>|</span> <a href=""> 资质证照 </a><span>|</span> <a href=""> 协议规则 </a><span>|</span> <a href=""> 下载App </a><span>|</span> <a href=""> 智能生活 </a><span>|</span> </div> <div class="header_cart"> <a href=""><i class="iconfont"></i> 购物车(0)</a> </div> <div class="header_info clearfix"> <a href="">登录</a><span>|</span> <a href="">注册</a><span>|</span> <a href="">消息通知</a> </div> </div> </div> <div class="header2"> <div class="container"> <div class="header2_log"> <a href="url" class="lr">小米官网</a> </div> <div class="header2_nav"> <ul class="nav_list clearfix"> <li class="nav_item2"> <a href="">全部商品分类</a> </li> <li class="nav_item"> <a href="">小米手机</a> </li> <li class="nav_item"> <a href="">Redmi 红米</a> </li> <li class="nav_item"> <a href="">电视</a> </li> <li class="nav_item"> <a href="">笔记本</a> </li> <li class="nav_item"> <a href="">家电</a> </li> <li class="nav_item"> <a href="">路由器</a> </li> <li class="nav_item"> <a href="">智能硬件</a> </li> <li class="nav_item"> <a href="">服务</a> </li> <li class="nav_item"> <a href="">社区</a> </li> </ul> </div> <div class="header2_search"> <form class="search-form" action=""> <input type="search" name="keyword" class="search-text"> <input type="submit" value="" class="search-button iconfont"> </form> </div> </div> </div> <div class="seckill"> <div class="seckill-head"></div> <div class="container"> <div id="seckillNav" class="seckill-nav"> <ul id="tabs"> <li class="active"><em>18:00</em><span><em>即将开始<br>距开始 01:02:20</em></span></li> <li><em>00:00</em><span>明日开始</span></li> <li><em>10:00</em><span>明日开始</span></li> <li><em>12:00</em><span>明日开始</span></li> <li><em>14:00</em><span>明日开始</span></li> </ul> </div> <div id="lists" class="seckill-goods"> <ul class="clearfix active"> <li> <div class="bg"> <img src="./img/1.png" alt=""> </div> <div class="info"> <a href="" class="name">小米移动电源2C 20000mAh 白色</a> <p class="tips">大容量,一个就够用</p> <!-- <del></del>是删除标签 --> <p class="price">1元 <del>129元</del></p> <a href="" class="btn">登录后抢购</a> <p class="person">已有83852人设置提醒</p> </div> </li> </ul> <ul class="clearfix"> <li> <div class="bg"> <img src="./img/2.png" alt=""> </div> <div class="info"> <a href="" class="name">小米移动电源2C 20000mAh 白色</a> <p class="tips">大容量,一个就够用</p> <!-- <del></del>是删除标签 --> <p class="price">1元 <del>129元</del></p> <a href="" class="btn">登录后抢购</a> <p class="person">已有83852人设置提醒</p> </div> </li> </ul> <ul class="clearfix"> <li> <div class="bg"> <img src="./img/3.png" alt=""> </div> <div class="info"> <a href="" class="name">小米移动电源2C 20000mAh 白色</a> <p class="tips">大容量,一个就够用</p> <!-- <del></del>是删除标签 --> <p class="price">1元 <del>129元</del></p> <a href="" class="btn">登录后抢购</a> <p class="person">已有83852人设置提醒</p> </div> </li> </ul> <ul class="clearfix"> <li> <div class="bg"> <img src="./img/2.png" alt=""> </div> <div class="info"> <a href="" class="name">小米移动电源2C 20000mAh 白色</a> <p class="tips">大容量,一个就够用</p> <!-- <del></del>是删除标签 --> <p class="price">1元 <del>129元</del></p> <a href="" class="btn">登录后抢购</a> <p class="person">已有83852人设置提醒</p> </div> </li> </ul> <ul class="clearfix"> <li> <div class="bg"> <img src="./img/1.png" alt=""> </div> <div class="info"> <a href="" class="name">小米移动电源2C 20000mAh 白色</a> <p class="tips">大容量,一个就够用</p> <!-- <del></del>是删除标签 --> <p class="price">1元 <del>129元</del></p> <a href="" class="btn">登录后抢购</a> <p class="person">已有83852人设置提醒</p> </div> </li> </ul> </div> <p class="seckill-notice"> *小米闪购活动规则:小米闪购商品不享受该商品在小米商城的其他优惠政策(包括但不限于优惠券、赠品、满减、满赠等)<br>温馨提示:因可能存在系统缓存、页面更新导致价格变动异常等不确定性情况出现,如您发现活动商品标价或促销信息有异常,请您立即联系小米客服,以便我们及时补正。 </p> </div> </div> <script src="js/index.js"></script> </body> </html>
body { /* margin和padding用于去白边 */ margin: 0; padding: 0; height: 2500px; } ul, li { margin: 0; padding: 0; } ul { list-style-type: none; } a { /* 去掉下划线 */ text-decoration: none; } /* header */ .header { /* border: 1px solid black; */ background-color: #333; height: 40px; } .container { /* border: 1px solid black; */ margin: 0 auto; /* 居中设置 */ width: 1226px; } /* 解决浮动导致的边界塌陷 */ .container::before, .container::after,.clearfix::before, .clearfix::after { content: ""; display: table; } .container::after, .clearfix::after { clear: both; } .header_nav { float: left; /* 设置居中 */ height: 40px; line-height: 40px; font-size: 0; } .header_nav span { font-size: 12px; } .header_info { float: right; } .header_cart { float: right; } .header a { color: #b0b0b0; font-size: 12px; } /* 设置鼠标悬停变色 */ .header a:hover { color: #fff; } .header_cart a { display: block; height: 40px; line-height: 40px; /* 文本居中 */ text-align: center; width: 120px; background-color: #424242; } .header_cart a:hover { color: #ff6700; background-color: #fff; } .header_info a { float: left; padding: 0 5px; line-height: 40px; height: 40px; } .header_info span { float: left; font-size: 12px; color: #424242; line-height: 40px; height: 40px; } /* header2 */ .header2 { height: 100px; } .header2_log { float: left; width: 62px; height: 55px; margin-top: 22px; } .header2_log a { display: block; width: 55px; height: 55px; background: #ff6700 url(../img/mi-logo.png) no-repeat 50% 50%; } /* 确保图标消失时也可以点 */ .header2_log .lr { text-align: left; text-indent: -9992em; } .header2_nav { float: left; width: 820px; height: 100px; } .header2_nav .nav_list { width: 820px; height: 88px; font-size: 16px; padding: 12px 0 0 30px; } .header2_nav .nav_list .nav_item { /* 使列表横向 */ float: left; } .header2_nav .nav_list .nav_item a { display: block; padding: 26px 10px 38px; color: #333; } .header2_nav .nav_list .nav_item a:hover { color: #ff6700; } .header2_nav .nav_list .nav_item2 { float: left; width: 127px; padding: 0 15px 0 0; } .header2_nav .nav_list .nav_item2 a { display: block; padding: 26px 0px 38px; text-align: right; color: #333; } .header2_search { float: right; width: 296px; height: 50px; margin-top: 25px; } .header2_search .search-form{ position: relative; display: block; width: 296px; height: 50px; } .header2_search .search-form .search-text{ display: block; position: absolute; top: 0; right: 51px; width: 245px; height: 50px; line-height: 50px; border: 1px solid #e0e0e0; outline: 0; } .header2_search .search-form .search-button{ position: absolute; top: 0; right: 0; display: block; width: 52px; height: 50px; border: 1px solid #e0e0e0; font-size: 24px; line-height: 24px; background-color: #fff; color: #616161; outline: 0; } .header2_search .search-form .search-button:hover{ background-color: #ff6700; color: #fff; } /* seckill */ .seckill { background-color: #f5f5f5; } .seckill .seckill-head{ margin-top: 19px; height: 170px; background: url(../img/seckill-head.jpg) no-repeat 50% 0; } .seckill-navfixed{ position: fixed; top: 60px; } .seckill .seckill-nav{ margin: -68px 0 22px; } .seckill .seckill-navfixed{ position: fixed; top: 60px; } .seckill .seckill-nav ul{ width: 1226px; height: 68px; background: #414141; } .seckill .seckill-nav li{ display: block; float: left; width: 20%; color: #fff; height: 68px; line-height: 68px; text-align:center; cursor: pointer; } .seckill .seckill-nav li em{ display: inline-block; font-style: normal; margin-left: 30px; font-size: 18px; line-height: 1px; vertical-align: middle; } .seckill .seckill-nav span{ display: inline-block; text-align: left; line-height: 1px; margin-left: 15px; vertical-align: middle; font-size: 14px; } .seckill .seckill-nav .active{ background: #f1393a; } .seckill .seckill-nav ul li span em{ display: inline-block; font-size: 14px; margin-left: 0; font-style: normal; text-align: left; line-height: 20px; } .seckill .seckill-goods .active{ display: block; } .seckill .seckill-goods ul{ display: none; margin-right: -13px; } .seckill .seckill-goods li{ float: left; width: 400px; height: 190px; background-color: #414141; margin-right: 13px; margin-bottom: 13px; } .seckill .seckill-goods .bg{ float: left; width: 190px; height: 190px; } .seckill .seckill-goods .info{ height: 190px; width: 190px; margin-left: 200px; color: #fff; padding-top: 30px; } .seckill .seckill-goods .bg img{ height: 190px; width: 190px; } .seckill .seckill-goods .info .name{ font-size: 16px; color: #fff; height: 16px; line-height: 16px; display: block; /* 取消换行 */ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .seckill .seckill-goods .info .tips{ font-size: 12px; line-height: 12px; color: #b0b0b0; margin-top: 10px; } .seckill .seckill-goods .info .price{ font-size: 16px; line-height: 16px; color: #f1393a; margin-top: 14px; } .seckill .seckill-goods .info .price del{ color: #999; font-size: 12px; line-height: 12px; margin-left: 10px; margin-bottom: 0; } .seckill .seckill-goods .info .btn{ display: inline-block; width: 118px; height: 28px; line-height: 28px; font-size: 14px; color: #fff; text-align: center; background-color: #f1393a; border: 1px solid #f1393a; } .seckill .seckill-goods .info .person{ font-size: 12px; line-height: 12px; color: #b0b0b0; margin-top: 10px; } .seckill-notice { font-size: 12px; color: #999; margin-top: 100px; padding-bottom: 35px; }
var tabs = document.getElementById("tabs").getElementsByTagName("li"); console.log(tabs); var lists = document.getElementById("lists").getElementsByTagName("ul"); console.log(lists); for(var i = 0; i< tabs.length; i++){ tabs[i].onclick = showlist; } function showlist(){ for( var i = 0; i<tabs.length; i++){ if( tabs[i] === this){ tabs[i].className = "active"; lists[i].className = "clearfix active"; } else { tabs[i].className = ""; lists[i].className = "clearfix"; } } } var seckillNav = document.getElementById("seckillNav"); window.onscroll = function(){ var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop || 0; if( scrollTop >= 260){ seckillNav.className = "seckill-nav seckill-navfixed" }else { seckillNav.className = "seckill-nav"; } console.log(scrollTop); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。