1. 程式人生 > >開發”小米商城官網首頁”(靜態頁面)

開發”小米商城官網首頁”(靜態頁面)

配件 16px -i ont div name :after 路由器 clas

開發“小米官方網站首頁”(靜態頁面)

官網 https://www.mi.com/

技術分享圖片

HTML

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>小米商城</title>
    <meta http-equiv="x-ua-compatible" content="IE=edge">
    <meta name="description" content="小米商場官方網站">
    <meta name="
keywords" content="小米" > <link rel="icon" href="images/logo.png"> <link rel="stylesheet" href="./css/index.css"> </head> <body> <div class="wrap"> <!--頂部導航欄--> <div class="topheader"> <div class="container"> <!--導航--> <div class
="topheader-navi"> <a href="#">小米商城</a> <span class="sep">|</span> <a href="#">MIUI</a> <span class="sep">|</span> <a href="#">loT</a> <span class
="sep">|</span> <a href="#">雲服務</a> <span class="sep">|</span> <a href="#">水滴</a> <span class="sep">|</span> <a href="#">金融</a> <span class="sep">|</span> <a href="#">有品</a> <span class="sep">|</span> <a href="#">Select Region</a> </div> <!--購物車--> <div class="topheader-cart"> <a href="#"> <span class="icon"></span> <span class="shop-cart">購物車(0)</span> </a> </div> <!--用戶信息--> <div class="topheader-info"> <a href="#">登錄</a> <span class="sep">|</span> <a href="#">註冊</a> <span class="sep">|</span> <a href="#">消息通知</a> </div> </div> </div> <!--header--> <div class="header"> <div class="container"> <!--logo--> <div class="header-logo"> <a href="#"><img class="logo" src="images/logo.png" alt="小米圖標"></a> </div> <!--導航--> <div class="header-navi"> <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> <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="header-search"> <form action="http://list.mi.com/" method="get"> <label for="search"></label> <input type="text" name="search" id="search"> <span class="hot-words"> <a href="#">小米小愛音響mini </a> <a href="#">紅米Note5 </a> </span> <input type="submit" value="" id="submit"> </form> </div> </div> </div> <!--主要內容--> <div class="content"> <div class="container"> <!--上部分--> <div class="con-up"> <div class="up-l"> <ul> <li><a href="#">手機&nbsp;電話卡</a><span>&gt;</span></li> <li><a href="#">電視&nbsp;盒子</a><span>&gt;</span></li> <li><a href="#">筆記本</a><span>&gt;</span></li> <li><a href="#">智能&nbsp;家電</a><span>&gt;</span></li> <li><a href="#">健康&nbsp;家居</a><span>&gt;</span></li> <li><a href="#">出行&nbsp;兒童</a><span>&gt;</span></li> <li><a href="#">路由器&nbsp;手機配件</a><span>&gt;</span></li> <li><a href="#">移動電源&nbsp;插線板</a><span>&gt;</span></li> <li><a href="#">耳機&nbsp;音響</a><span>&gt;</span></li> <li><a href="#">生活&nbsp;米兔</a><span>&gt;</span></li> </ul> </div> <div class="up-2"> <a href="#"> <img src="images/母親節.jpg" alt="內容圖片" style="width: 1245px;height: 465px"> </a> </div> </div> <!--下部分--> <div class="con-down"> <div class="down-l"> <ul> <li><div class="p-1"></div><p>選購手機</p></li> <li><div class="p-2"></div><p>企業團購</p></li> <li><div class="p-3"></div><p>F碼通道</p></li> <li><div class="p-4"></div><p>米粉卡</p></li> <li><div class="p-5"></div><p>以舊換新</p></li> <li><div class="p-6"></div><p>話費充值</p></li> </ul> </div> <div class="down-2"> <ul> <li><a href="#"><img src="images/紅米5A.jpg" alt="小米圖片"></a></li> <li><a href="#"><img src="images/小米MIX2.jpg" alt="紅米圖片"></a></li> <li><a href="#"><img src="images/凈水器.jpg" alt="凈水器圖片"></a></li> </ul> </div> </div> </div> </div> <!--右側固定欄--> <div class="bar-right"> <ul id="right-ul"> <li><div class="fixed-1"></div><p>掃一掃</p></li> <li ><div class="fixed-2"></div><p>個人中心</p></li> <li ><div class="fixed-3"></div><p>聯系客服</p> <li ><div class="fixed-4"></div><p>購物車</p></li> </ul> </div> <!--底部--> <div class="footer"> <p>搜索黑科技,小米為發燒而生!</p> </div> </div> </body> </html>

CSS

index.css

*{
    padding: 0;
    margin: 0;
}
.wrap{
    width: 100%;
    overflow: hidden; /*有父子關系的margin 防止外邊距合並*/
    background-color: rgba(245,245,245,0.98); /*設置透明度*/
}
a{text-decoration: none;}
ul>li{ list-style: none;} /*兒子選擇器*/

.topheader{
    height: 40px;
    line-height:40px;/*行高*/
    font-size:12px;
    background-color: #333;
}
.topheader a{
    color:#b0b0b0; /*字體顏色*/
}
.topheader a:hover{    /* 偽類選擇器 hover鼠標懸停時超鏈接狀態*/
    color: white;
}
.topheader .sep{
    color: #424242;
    margin: 0 2px;  /*外邊距*/
}
.container{
    width: 1225px; overflow: hidden;margin: 0 auto;
}
.topheader-navi{
    float: left;
}
.topheader-cart,.topheader-info{
    float: right
}
.topheader-cart .icon{     /*給購物車添加背景圖片*/
    background: url("../images/shop1.png") 3px 24px;
    width: 35px;
    height: 22px;
    display: inline-block;/*行內塊元素 同時具有行內和和塊級元素,和其他元素在一行,距離都可以設置*/
    position: relative;
    top:6px;
}
.topheader-cart a{
    /*display: block; !*塊級元素,每個塊級元素都從新的一行開始,距離都可設置*!*/
    margin-left: 15px;
    padding: 0 15px;
}
.topheader-cart a:hover{
    background-color: white;
    color: rgba(255,103,0,0.98);
}

.header{
    height: 100px;
    line-height: 100px;
    overflow: hidden;
}
.header-logo,.header-navi{
    float: left;
    height: 100px;
}
.header-logo .logo{
    margin-right: 10px;
    margin-top: 20px;}

.header-search{
    float: right;
    position: relative;
}
.header-navi ul li{
    float: left;
    margin: 0 auto;
    padding: 0 10px;
    color: black
}
.header-navi ul li a{
    color: #333;
    font-size: 16px;
}
.header-navi ul li a:hover{
    color: rgba(255,103,0,0.98);
}

.header-search input[type="text"]{
    height: 44px;
    width: 243px;
    border: 1px solid #e0e0e0;
    margin-right: -1px;
}
.header-search input[type="text"]:hover{
    border: 1px solid #b0b0b0;
}
.header-search input[type="text"]:focus{    /*獲取焦點時的樣式*/
    outline:none;  /*輪廓是繪制於元素周圍的一條線,位於邊框邊緣的外圍,可起到突出元素的作用*/
}
.hot-words{
    font-size: 12px;
    position: absolute;
    right: 40px;}
.hot-words a{
    background-color: #eee;
    color: #757575;
    padding: 3px 6px;
    position: relative;
    top: 2px;
    right: 16px;
}
.hot-words a:hover{
    background-color: rgba(255,103,0,0.98);
    color: white;
}
.header-search input[type="submit"]{
    height: 45px; width: 45px;
    background: url("../images/search1.png") no-repeat 3px 6px;
    border: 1px solid #e0e0e0;
    position: relative;
    top: 17px;
    cursor: pointer;  /*設置鼠標形狀, 變成小手了*/
    left: -5px;
}
.header-search input[type="submit"]:hover{
    background: url("../images/search2.png") no-repeat 8px 8px;
    background-color: rgba(255,107,0,0.98);
}

.content .con-up .up-l{
    background-color: rgba(89,89,89,0.9);
    width: 240px;
    position: absolute;
}
.con-up ul:before,.con-up ul:after{   /*用子盒子來填充父盒子 解決浮動產生的問題*/
    content: "";
    height: 26px;
    display: block;
}
.con-up ul li{
    padding: 10px 25px;
}
.con-up ul li:hover{
    background-color: rgba(255,103,0,0.98);
}
.con-up ul li a{
    color: white;}
.con-up ul li span{    /*設置空格*/
    float: right;
    color: white;}

.con-down{
    overflow: hidden;
    padding-top: 10px;
}
.con-down .down-l{
    width: 240px;
    overflow: hidden;
    background-color: rgba(95,87,80,1);
    float: left;
}
.con-down ul{
    overflow: hidden;
}
.con-down .down-l ul li{
    float: left;
    width: 78px;
    height: 83px;
    border: 1px solid #665e57;
    text-align: center;  /*兩端居中*/
}
.down-l ul li p{
    color: #b0b0b0;
    position: relative;

    font-size: 15px;
}
.down-l ul li p:hover{
    color: white;
}

.down-l .p-1{
    background: url("../images/手機.png") no-repeat center;
    background-size: 50px; height: 60px;}
.down-l .p-2{
    background: url("../images/企業團購.png") no-repeat center;
    background-size: 50px; height: 60px;}
.down-l .p-3{
    background: url("../images/F碼通道.png") no-repeat center;
    background-size: 50px; height: 60px;}
.down-l .p-4{
    background: url("../images/米粉卡.png") no-repeat center;
    background-size: 50px; height: 60px;}
.down-l .p-5{
    background: url("../images/以舊換新.png") no-repeat center;
    background-size: 50px; height: 60px;}
.down-l .p-6{
    background: url("../images/話費充值.png") no-repeat center;
    background-size: 50px; height: 60px;}

.con-down .down-2{
    float: left;}
.con-down .down-2 ul li{
    float: left;
}
.down-2 img{
    width: 315px;
    height: 170px;
    margin-left: 13px;
}
.down-2 img:hover{
    box-shadow: 0 5px 1px #b0b0b0; /*box-shadow 向框添加一個或多個陰影*/
}

.bar-right{
    position: fixed;
    /*z-index: 3;*/
    right: 0;
    top: 250px;
    background-color: white; }
.bar-right ul li{
    font-size: 14px;
    padding: 10px;
    border: 1px solid #e0e0e0;
}
.bar-right ul li:hover{
    color: rgba(255,103,0,0.98);
    cursor: pointer;
}
.bar-right ul li p{
    text-align: center;
    padding-top: 5px;
}

.bar-right .fixed-1{
    background: url("../images/掃一掃.png") no-repeat center;
    background-size: 30px; height: 30px;
}
.bar-right .fixed-2{
    background: url("../images/個人中心.png") no-repeat center;
    background-size: 30px;
    height: 30px;}
.bar-right .fixed-3{
background: url("../images/聯系客服.png") no-repeat center;
    background-size: 30px;
    height:30px ;
}
.bar-right .fixed-4{
background: url("../images/購物車.png") no-repeat center;
    background-size: 30px;
    height:30px ;
}
.footer p{
    text-align: center;
    color: #b0b0b0;
    font-size: 16px;}

效果展示:

技術分享圖片

開發”小米商城官網首頁”(靜態頁面)