HTML+CSS模仿小米秒杀网站

HTML+CSS模仿小米秒杀网站

    • 前言
    • 效果
    • 代码
      • html代码
      • css代码
      • js代码

前言

学完了HTML和CSS就模仿小米秒杀的网站弄了个简单的静态网页!!!

效果

HTML+CSS模仿小米秒杀网站_第1张图片

代码

html代码


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小米闪购-小米商城title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link rel="stylesheet" href="./css/style.css">
    <link rel="stylesheet" href="./css/iconfont.css">
head>
<body>
    
    <div class="site-topbar">
        <div class="container">
            <div class="topbar-nav">
                <a href="">小米商城a><span>|span>
                <a href="">MIUIa><span>|span>
                <a href="">IoTa><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="">下载Appa><span>|span>
            div>
            <div class="topbar-car">
                <a href=""><i class="iconfont">i> 购物车<span>(0)span>a>
            div>
            <div class="topbar-info clearfix">
                <a href="">登录a><span>|span>
                <a href="">注册a><span>|span>
                <a href="" class="sep">消息通知a>
            div>
        div>
    div>
    
    <div class="header">
        <div class="container">
            <div class="header-logo">
                <a href="http://www.mi.com" class="lr" title="小米官网">a>
            div>
            <div class="header-nav">
                <ul class="nav-list clearfix">
                    <li class="nav-category">
                        <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="header-search">
                <form action="" class="search-form">
                    <input type="search" name="keyword" class="search-text">
                    <input type="submit" value="" class="search-btn iconfont">
                form>
            div>
        div>
    div>
    
    <div class="seckill">
        <div class="seckill-head">div>
        <div class="container">
            <div class="seckill-nav">
                <ul id="tabs">
                    <li class="active"><em>14:00em><span><em>抢购中br>距结束 02:27:18em>span>li>
                    <li><em>20:00em><span>即将开始span>li>
                    <li><em>22:00em><span>即将开始span>li>
                    <li><em>00:00em><span>明日开始span>li>
                    <li><em>10:00em><span>明日开始span>li>
                ul>
            div>
            <div class="seckill-goods">
                <ul class="clearfix">
                    <li>
                        <div class="bg"><img src="./img/kongtiao.jpg" alt="">div>
                        <div class="info">
                            <a href="" class="goods-name">自清洁|小米互联网空调1.5匹a>
                            <p class="goods-tips">高效制冷/热,全屋互联p>
                            <p class="goods-price">1799.00元 <del>2699元del>p>
                            <a href="" class="btn">登录后抢购a>
                        div>
                    li>
                    <li>
                        <div class="bg"><img src="./img/yinxiang.jpg" alt="">div>
                        <div class="info">
                            <a href="" class="goods-name">小米AI音箱a>
                            <p class="goods-tips">听音乐、语音遥控家电p>
                            <p class="goods-price">199.00元 <del>299元del>p>
                            <a href="" class="btn">登录后抢购a>
                        div>
                    li>
                    <li>
                        <div class="bg"><img src="./img/zhijin.jpg" alt="">div>
                        <div class="info">
                            <a href="" class="goods-name">日常元素抽纸 青春版 24包/箱 a>
                            <p class="goods-tips">精选原生竹浆,健康环保p>
                            <p class="goods-price">27.90元 <del>32.90元del>p>
                            <a href="" class="btn">登录后抢购a>
                        div>
                    li>
                    <li>
                        <div class="bg"><img src="./img/maojin.jpg" alt="">div>
                        <div class="info">
                            <a href="" class="goods-name">最生活毛巾·Air(10条装) 白色+素蓝 a>
                            <p class="goods-tips">给生活一条好毛巾p>
                            <p class="goods-price">99.00元 <del>169元del>p>
                            <a href="" class="btn">登录后抢购a>
                        div>
                    li>
                    <li>
                        <div class="bg"><img src="./img/diannao.jpg" alt="">div>
                        <div class="info">
                            <a href="" class="goods-name">RedmiBook 13 锐龙版 R5 16G 512G SATA SSD 集显 月光银 a>
                            <p class="goods-tips">全面屏高性能轻薄本p>
                            <p class="goods-price">3799.00元 <del>3999元del>p>
                            <a href="" class="btn">登录后抢购a>
                        div>
                    li>
                    <li>
                        <div class="bg"><img src="./img//xiyiji.jpg" alt="">div>
                        <div class="info">
                            <a href="" class="goods-name">Redmi全自动波轮洗衣机1S 8kg 灰色 a>
                            <p class="goods-tips">小身材大容量,可预约p>
                            <p class="goods-price">799.00元 <del>899元del>p>
                            <a href="" class="btn">登录后抢购a>
                        div>
                    li>
                    <li>
                        <div class="bg"><img src="./img/jiqiren.jpg" alt="">div>
                        <div class="info">
                            <a href="" class="goods-name">米家扫拖一体机器人 白色 a>
                            <p class="goods-tips">扫得干净,拖得彻底p>
                            <p class="goods-price">1599.00元 <del>1999元del>p>
                            <a href="" class="btn">登录后抢购a>
                        div>
                    li>
                    <li>
                        <div class="bg"><img src="./img/diannao2.jpg" alt="">div>
                        <div class="info">
                            <a href="" class="goods-name"> 14 Ⅱ R5 8G 512G 银色 a>
                            <p class="goods-tips">全面屏高性能轻薄本p>
                            <p class="goods-price">3599.00元 <del>3799元del>p>
                            <a href="" class="btn">登录后抢购a>
                        div>
                    li>
                    <li>
                        <div class="bg"><img src="./img/jinghuaqi.jpg" alt="">div>
                        <div class="info">
                            <a href="" class="goods-name">米家空气净化器 2S a>
                            <p class="goods-tips">好空气看得见p>
                            <p class="goods-price">699.00元 <del>899元del>p>
                            <a href="" class="btn">登录后抢购a>
                        div>
                    li>
                ul>
            div>
            <p class="seckill-notice">*小米秒杀活动规则: <br>
                1.秒杀商品是否参加活动、最终秒杀成功的商品,以订单结算页显示为准,活动包括但不限于优惠券、赠品、满减、满赠等;<br>
                2.秒杀商品数量有限,活动以下单支付成功为准,请加入购物车后尽快下单支付;<br>
                3.秒杀价不含运费,最终以订单结算页价格为准;<br>
                4.订单中商品的数量、颜色、型号等,以订单结算页为准。<br>
                温馨提示:因可能存在系统缓存、页面更新导致价格变动异常等不确定性情况出现,如您发现活动商品标价或促销信息有异常,请您立即联系小米客服,以便我们及时补正。
            p>
        div>
    div>
    <script src="./js/index.js">script>

body>
html>

css代码

/* 初始化样式 */
* {
    margin: 0;
    padding: 0;
}
body {
    font: 14px/1.5 "Helvetica Neue",Helvetica,Arial,"Microsoft Yahei","Hiragino Sans GB","Heiti SC","WenQuanYi Micro Hei",sans-serif;
}
a {
    text-decoration: none;
}
ul {
    list-style-type: none;
}
.container {
    margin: 0 auto;
    width: 1226px;
}
/* 清除浮动 */
.container::after,
.container::before,
.clearfix::after,
.clearfix::before {
    content: "";
    display: table;
}
.container::after,
.clearfix::after {
    clear: both;
}
/* 顶部菜单栏样式 */
.site-topbar {
    background-color: #333;
    height: 40px;
}
.site-topbar a {
    color: #b0b0b0;
    font-size: 12px;
}
.site-topbar a:hover{
    color: #fff;
}

.topbar-nav {
    float: left;
    height: 40px;
    line-height: 40px;
    font-size: 0;
}
.topbar-nav span {
    font-size: 12px;
    color: #424242;
    font-family: sans-serif;
    margin: 0.5em;
}
.topbar-car,
.topbar-info {
    float:right;
}
.topbar-car a {
    display:block;
    height: 40px;
    line-height: 40px;
    text-align: center;
    width: 120px;
    background-color: #424242;
}
.topbar-car a:hover {
    color: #ff6700;
    background-color: #fff;
}
.topbar-car span {
    font-size: 12px;
}
.topbar-info {
    margin-right: 15px;
}
.topbar-info a {
    float: left;
    padding: 0 5px;
    height: 40px;
    line-height: 40px;
}
.topbar-info span {
    float: left;
    font-size: 12px;
    color: #424242;
    font-family: sans-serif;
    height: 40px;
    line-height: 40px;
}
.topbar-info .sep {
    padding: 0 10px;
}
/* 页头导航栏样式 */
.header {
    height: 100px;

}
.header-logo {
    float: left;
    width: 62px;
    margin-top: 22px;
    height: 55px;
}
.header-logo a {
    display: block;
    width: 49px;
    height: 49px;
    background: #ff6700 url(../img/mi-logo.png);
    text-align: center;
}
/* .header-logo a.lr {
    text-align: left;
    text-indent: -9992em;
} */
.header-nav {
    float: left;
    width: 820px;
    height: 100px;
}
.header-nav .nav-list {
    width: 820px;
    height: 88px;
    font-size: 16px;
    padding: 10px 0 0 30px;
}
.header-nav .nav-list .nav-category {
    float: left;
    width: 127px;
    padding: 0 15px 0 0;
}
.header-nav .nav-list .nav-category a{
    display: block;
    padding: 26px 0px 38px;
    text-align: right;
    color: #333;
}
.header-nav .nav-list .nav-item {
    float: left;
}
.header-nav .nav-list .nav-item a{
    display: block;
    padding: 26px 10px 38px;
    color: #333;
}
.header-nav .nav-list .nav-item a:hover {
    color: #ff6700;
}
.header-search {
    float: right;
    width: 296px;
    height: 50px;
    margin-top: 25px;
}
.header-search .search-form {
    position: relative;
    display: block;
    width: 296px;
    height: 50px;
}
.header-search .search-form .search-text{
    position: absolute;
    top: 0;
    right: 51px;
    display: block;
    width: 245px;
    height: 50px;
    line-height: 50px;
    border: 1px solid #e0e0e0;
    outline: 0;
}
.header-search .search-form .search-btn{
    position: absolute;
    top: 0;
    right: 0;
    display: block;
    width: 52px;
    height: 50px;
    font-size: 24px;
    line-height: 24px;
    border: 1px solid #e0e0e0;
    outline: 0;
    background: #fff;
    color: #616161;
}
.header-search .search-form .search-btn:hover {
    background-color: #ff6700;
    color: #fff;
}
/* 主体样式 */
.seckill {
    background-color: #f5f5f5;
}
.seckill-head {
    height: 170px;
    margin-top: 19px;
    background: url(../img/xiaomimiaosha.jpg) no-repeat 50% 0;
}
.seckill-nav {
    margin: -68px 0 22px;
}
.seckill-nav ul {
    height: 68px;
    background-color: #414141;
}
.seckill-nav ul li {
    display: block;
    float: left;
    color: #fff;
    width: 20%;
    height: 68px;
    line-height: 68px;
    text-align: center;
    cursor: pointer;
}
.seckill-nav li em {
    display: inline-block;
    margin-left: 30px;
    font-style: normal;
    font-size: 18px;
    line-height: 1;
    vertical-align: middle;
} 
.seckill-nav li span {
    display: inline-block;
    margin-left: 15px;
    text-align: left;
    line-height: 1;
    vertical-align: middle;
    font-size: 14px;
}
.seckill-nav ul li span em {
    display: inline-block;
    text-align: left;
    font-style: normal;
    font-size: 14px;
    margin-left: 0;
    line-height: 20px;
}
.seckill-nav .active {
    background-color: #f1393a;
}

/* 商品信息样式 */
.seckill-goods ul {
    /* border: 1px solid black; */
    margin-right: -13px;
}
.seckill-goods li {
    float: left;
    width: 400px;
    height: 190px;
    background-color: #fff;
    margin-right: 13px;
    margin-bottom: 13px;

}

.seckill-goods .bg {
    float: left;
    width: 190px;
    height: 190px;
    /* border: 1px solid red; */
}
.seckill-goods .bg img {
    height: 190px;
}
.seckill-goods .info {
    padding-top: 30px;
    float: right;
    width: 190px;
    height: 190px;
    /* border: 1px solid red; */
}
.seckill-goods .info .goods-name {
    font-size: 16px;
    color:#333;
    height: 16px;
    line-height: 16px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.seckill-goods .info .goods-tips {
    font-size: 12px;
    height: 12px;
    line-height: 12px;
    color: #b0b0b0;
    margin-top: 10px;
}
.seckill-goods .info .goods-price {
    font-size: 16px;
    height: 16px;
    line-height: 16px;
    color: #f1393a;
    margin-top: 20px;
    margin-bottom: 0;

}
.seckill-goods .info .goods-price del {
    color: #999;
    font-size: 12px;
    margin-left: 12px;
}
.seckill-goods .info .btn {
    display: inline-block;
    width: 118px;
    height: 28px;
    color: #fff;
    font-size: 14px;
    line-height: 28px;
    text-align: center;
    background-color: #f1393a;
    margin-top: 20px;
    border: 1px solid #f1393a;
}
.seckill-notice {
    font-size: 12px;
    color: #999;
    margin-top:100px;
    padding-bottom:30px;
}

js代码

var tabs=document.getElementById("tabs").getElementsByTagName("li");
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";
        }
        else{
            tabs[i].className="";
        }
        
    }
}

你可能感兴趣的:(HTML+CSS模仿小米秒杀网站)