仿小米商城

仿小米商城(1)——导航条



一、页面分析

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

从整体来看

主要有以下特点:
1.页面样式重复部分多
2.不同的页面含有公共部分的内容——>创建style.css来放公共部分

从局部(导航条)来看

登录前:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

登录后:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
未登录前分为top-lt和top-gt两个部分
未登录前导航条

导航条pub-top
左侧top-lt右侧top-gt
超链接a登录login购物车car-box
下载二维码div(登录注册消息)超链接a购物车超链接a购物车空提示信息div
登录后导航条: 左侧无变化,右侧发生了改变
导航条pub-top
左侧top-lt右侧top-gt
超链接a用户信息userinfo购物车car-box2
下载二维码divuser下拉列表gt-tit消息提醒,我的订单购物车超链接apop购物车商品详细信息

二、代码部分

index.html代码:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description"
        content="小米官网直营小米公司旗下所有产品,包括Xiaomi手机系列Xiaomi 11 Ultra、MIX FOLD,Redmi 红米系列Redmi Note 9、Redmi K40 Pro,小米电视、笔记本、米家智能家居等,同时提供小米客户服务及售后支持.">
    <meta name="keywords" content="Xiaomi,redmi,Xiaomi11 Ultra,Redmi Note 9,Xiaomi MIX Alpha,小米商城">
    <title>小米商城 - Xiaomi 11 Ultra、Redmi K40 Pro、MIX FOLD,小米电视官方网站</title>
    <!-- 重置默认样式 -->
    <link rel="stylesheet" href="css/reset.css">
    <!-- 公共部分 -->
    <link rel="stylesheet" href="css/style.css">
    <!-- 首页样式 -->
    <link rel="stylesheet" href="css/index.css">
    <!-- 引入网页标题图标 -->
    <link rel="shortcut icon" href="img/icons/favicon.ico" type="image/x-icon" />
    <!-- 引入向下箭头、购物车等图标 -->
    <link rel="stylesheet" href="img/icons/font_3218970_7whji418qhl/iconfont.css">

</head>

<body>
    <div class="pub-top">
        <div class="container">
            <div class="top-lt">
                <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="#" class="download">
                    下载app
                    <div class="down-box">
                        <b></b>
                        <img src="img/download.png" alt=""><i>小米商城APP</i>
                    </div>
                </a><span>|</span>
                <a href="#">Select Location</a>
            </div>
            <div class="top-gt">
                <!-- <div class="car-box">
                  <a href="" class="car-tit"><span class="icon-gouwuche"></span>购物车(0)</a>
                    <div class="car-info"><span>购物车中还没有商品,赶紧选购吧!</span></div>
                </div> -->
                <div class="car-box2">

                    <a href="" class="car-tit2"><span class="icon-cart-full"></span>购物车(1)</a>
                    <div class="pop">
                        <ul>
                            <li>
                                <div class="one">
                                    <img src="img/a.png" alt="">
                                    <span class="one-produce">Redmi K50电竞<br>版
                                        12GB+256GB</span>
                                        <span class="one-price">3899元 * 1
                                    </span><span class="icon-qingchu"></span>
                                </div>
                            </li>
                        </ul>
                        <div class="price">
                            <p class="total-produce">共1件商品</p>
                            <h4 class="total-price">3899元</h4>
                        </div>
                        <a href="" alt="btn" class="buy">去购物车结算</a>
                    </div>
                   
                </div>

                <!-- <div class="login">
                    <a href="#">登录</a><span>|</span>
                    <a href="#">注册</a><span>|</span>
                    <a href="#">消息通知</a>
                </div> -->
                <div class="userinfo">
                    <div class="user">
                        <a href="" class="user-tit">用户
                            <span class="icon-xiangxiajiantou"></span></a>
                        <ul>
                            <li><a href="">个人中心</a></li>
                            <li><a href="">评价晒单</a></li>
                            <li><a href="">我的喜欢</a></li>
                            <li><a href="">小米账户</a></li>
                            <li><a href="">退出登录</a></li>
                        </ul>
                    </div>
                    <div class="gt-tit">
                        <span>|</span>
                        <a href="" >消息通知</a>
                        <span>|</span>
                        <a href="" >我的订单</a>
                    </div>
                </div>
            </div>
            
           
        </div>
    </div>
    
</body>

</html>

重置默认样式 reset.css代码

body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td{
    margin:0;padding:0;
}
body,button,input,select,textarea{
    font:12px/1.5tahoma,arial,\5b8b\4f53;
}
h1,h2,h3,h4,h5,h6{
    font-size: 100%;
}
address,cite,dfn,em,var{
    font-style: normal;
}
code,kbd,pre,samp{
    font-family: 'Courier New', Courier, monospace;
}
small{
    font-size: 12px;
}
ul,ol{
    list-style: none;
}
a{
    text-decoration:none;
    color: inherit;
}
sup{
    vertical-align: text-top;
}
sub{
    vertical-align:text-bottom;
}
legend{
    color:#000;
}
fieldset,img{
    border: 0;
}
button,input,select,textarea{
    font-size: 100%;
}
table{
    border-collapse: collapse;border-spacing: 0;
}

公共部分style.css代码:

/* 公共部分 */
/* 顶端公共部分 */
body{
    font-size: 14px;
    color: #333333;
}
.container{
    /* 版心宽 ,设置居中*/
    width: 1290px;
    margin-left: auto;
    margin-right: auto;
}
.pub-top{
    /* 导航栏高,颜色 */
    height: 42px;
    background-color: #333333;
    font-size: 5px;
}
.pub-top .top-lt{
    color: #b0b0b0;
    line-height: 42px;
    float: left;
    display: inline;
}
.pub-top .top-lt span{
    color: #424242;
    /* 设置|的左右边距 */
    padding: 0 3px;
}
.pub-top .top-lt a{
    /* 设置a为内联块状元素 */
    display: inline-block;
}
.pub-top .top-lt a:hover{
    color: #fff;
}
.pub-top .top-lt .download{
    position: relative;
}

.pub-top .top-lt .down-box{
    /* 设置相对于父元素居中 */
    width: 130px;
    background-color: #fff;
    position: absolute;
    left: 50%;
    margin-left: -65px;
    top: 42px;
    padding-top: 20px;
    /* 图片阴影 */
    box-shadow: 0 1px 5px #aaa;
    text-align: center;
    /* 隐藏二维码 */
    display: none;
}
.pub-top .top-lt .download:hover .down-box{
    display: block;
}
.pub-top .top-lt .down-box img{
    width: 88px;
    height: 88px;
    display: block;
    margin: 0 auto;
}
.pub-top .top-lt .down-box b{
    width: 18px;
    height: 18px;
    position: absolute;
    left: 50%;
    margin-left:-9px;
    background-image: url(../img/sjx.png);
    top: -18px;
}
.pub-top .top-lt a.download i{
    font-style: normal;
    color: #333333;
}
.pub-top .top-lt a.download:hover i{
    color: #333333;
}
.pub-top .top-gt {
    float: right;
    line-height: 42px;
}
.pub-top .top-gt .login{
    color: #b0b0b0;
    height: 42px;
    line-height: 42px;
    float:right;
}
.pub-top .top-gt .login span{
    color: #424242;
    padding: 0 3px;
}
/* 购物车空 */
.pub-top .top-gt .car-box{
    width: 128px;
    height: 42px;
    background-color: #424242;
    color: #333333;
    float: right;
    margin-left: 20px;
    text-align: center;
    position: relative;
}
.pub-top .top-gt .car-box .car-tit{
    height: 42px;
    color: #b0b0b0;
}

.pub-top .top-gt .car-box .car-tit .icon-gouwuche{
    font-family: iconfont;
    content: "\e602";
    color: #b0b0b0;
}
.pub-top .top-gt .car-box .car-info{
    display: none;
    height: 105px;
    width: 332px;
    text-align: center;
    line-height: 105px;
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
    position: absolute;
    right: 0px;
}
.pub-top .top-gt .car-box:hover .car-info{
    display: block;
}
.pub-top .top-gt .car-box:hover .car-tit{
    color: #ff6700;
}
.pub-top .top-gt .car-box:hover .icon-gouwuche{
    color: #ff6700;
}

.pub-top .top-gt .userinfo {
    float: right;
    /* margin-right: 20px; */
}
.pub-top .userinfo .user{
    display: inline-block;
    width: 120px;
    position: relative;
    text-align: center;
    /* left: 60px; */
}
.pub-top .top-gt span{
    padding: 0 3px;
    color: #424242;
}
.pub-top .userinfo .user-tit{
    line-height: 42px;
    color: #b0b0b0;
    display: block;
}
.pub-top .userinfo .user-tit img{
    width: 12px;
    height: 8px;
    
}
.pub-top .userinfo .gt-tit{
    line-height: 42px;
    color: #b0b0b0;
    float: right;
}
.pub-top .userinfo .gt-tit span{
    color: #424242;
}
.pub-top .userinfo .user ul a{
    display: block;
}
.pub-top .userinfo .user ul{
    display: none;
    position: absolute;
    left: 0;
    top: 42px;
    width: 120px;
    padding: 10px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.pub-top .userinfo .user li{
    line-height: 30px;
    padding: 4px 0;
}
.pub-top .userinfo .user .icon-xiangxiajiantou{
    color: #b0b0b0;
    font-family: iconfont;
    content: "\e65e";
}
.pub-top .userinfo .user li:hover{
    background-color: #f5f5f5;
    color: #ff6700;
}
.pub-top .userinfo .user:hover .icon-xiangxiajiantou{
    color: #ff6700;
}
.pub-top .userinfo .user:hover{
    background-color: #fff;
}
.pub-top .userinfo .user:hover .user-tit{
    color: #ff6700;
}

.pub-top .userinfo .user:hover ul{
    display:block;
    padding: 3px 0px;   
}
/* 购物车含有商品 */
.pub-top .top-gt .car-box2{
    width: 128px;
    height: 42px;
    background-color: #ff6700;
    color: #fff;
    float: right;
    margin-left: 20px;
    text-align: center;
    position: relative;
}
.pub-top .top-gt .car-box2 .car-tit2 .icon-cart-full{
    font-family: iconfont;
    content: "\e65e";
    color: #fff;
}
.pub-top .top-gt .car-box2 .pop .icon-qingchu{
    position: absolute;
    font-family: iconfont;
    content: "\e606";
    color: #000;
    right: 10px;
    padding-top: 20px;

}
.pub-top .top-gt .car-box2 .pop{
    display: none;
    height: 150px;
    width: 332px;
    text-align: center;
    padding: 20px 20px 30px 25px;
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
    position: absolute;
    right: 0px;
}
.pub-top .top-gt .car-box2:hover .pop{
    display: block;
}
.pub-top .top-gt .car-box2:hover{
    color: #ff6700;
    background-color: #fff;
}
.pub-top .top-gt .car-box2:hover .icon-cart-full{
    color: #ff6700;
}
.pub-top .top-gt .car-box2 .pop img{
    width: 88px;
    height: 88px;
    float: left;
}
.pub-top .top-gt .car-box2 .pop .one{
    position: relative;
}
.pub-top .top-gt .car-box2 .pop .one-produce{
    position: absolute;
    float: left;
    text-align: left;
    height: 28px;
    line-height: 28px;
    padding-top: 15px;
    right: 130px;
}
.pub-top .top-gt .car-box2 .pop .one-price{
    position: absolute;
    float: left;
    padding-top: 20px;
    padding-left: 20px;
}
.pub-top .top-gt .car-box2 .pop .icon-qingchu:hover{
    
    color: #000;
    float: left;
    font-size: 10px;

}

.pub-top .top-gt .car-box2 .pop .total-produce{
    position: absolute;
    margin-top: 100px;
    left: 30px;
    color: #b0b0b0;
    float: left;
    font-size: 18px;
}
.pub-top .top-gt .car-box2 .pop .total-price{
    color: #ff6700;
    float: left;
    position: absolute;
    margin-top: 130px;
    left: 30px;
    font-size: 20px;
}
.pub-top .top-gt .car-box2 .pop .buy{
    background-color: #ff6700;
    position: absolute;
    padding: 8px 20px;
    font-size: 17px;
    color: #fff;
    float: left;
    width: 150px;
    margin-left: 10px;
    margin-top: 100px;
    right: 30px;
}


个人心得总结

涉及方法及重点:
1.字体图标的使用方法
2.hover伪类的使用
3.元素居中

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值