網頁佈局------小米商城官網

昨夜小楼听风雨發表於2024-05-18

小米商城官網地址小米商城 - Xiaomi 14 Ultra、Redmi K70、MIX FOLD 3,小米電視官方網站

一、頭部

1、效果圖

2、網頁結構

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小米官網</title>
    <link rel="stylesheet"  href="./header.css" >
    <link rel="stylesheet" href="./iconfont.css">
    <link rel="stylesheet" href="./mi.css">
    <link rel="stylesheet" href="./reset.css">
    <link rel="icon" href="./images/favicon.ico" >
</head>
<body>
    <div class="header">
        <div class="content">
            <div class="header-left">
                <ul class="header-left-ul">
                    <li><a href="#">小米商城</a><span>|</span></li>
                    <li><a href="#">MIUI</a><span>|</span></li>
                    <li><a href="#">loT</a><span>|</span></li>
                    <li><a href="#">雲服務</a><span>|</span></li>
                    <li><a href="#">星天數科</a><span>|</span></li>
                    <li><a href="#">有品</a><span>|</span></li>
                    <li><a href="#">小愛開放平臺</a><span>|</span></li>
                    <li><a href="#">企業團購</a><span>|</span></li>
                    <li><a href="#">資質證照</a><span>|</span></li>
                    <li><a href="#">協議規則</a><span>|</span></li>
                    <li class="header-download"><a href="#">
                        下載app</a><span>|</span>
                        <div class="header-download-div">
                            <img  src="./images/78c30d4f259ed43ab20e810a522a6249.png" />
                            <span>小米商城APP</span>
                        </div>
                    
                    </li>
                    <li><a href="#">智慧生活</a><span>|</span></li>
                    <li><a href="#">Select Location</a><span>|</span></li>
                </ul>
            </div>
            <div class="header-right">
                <ul class="header-right-ul">
                    <li><a href="#">登入</a><span>|</span></li>
                    <li><a href="#">註冊</a><span>|</span></li>
                    <li><a href="#">訊息通知</a><span>|</span></li><span>|</span>
                    <li class="shop-li">
                        <a href="#">
                            <i class="iconfont">&#xe653;</i>購物車(0)
                            <div class="shop-div">
                                <span>購物車中還沒有商品,趕緊選購吧!</span>
                            </div>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</body>
</html>

3、css樣式

/* 頭部 */
*{
    margin: 0;
    padding: 0;
}
/* 頭部設定 */
.header{
    width: 100%;
    height: 40px;
    background-color: #333;

}
.content{
    width: 1226px;
    height: 40px;
    margin: 0 auto;
    text-align: center;
    line-height: 40px;
}
li{
    list-style-type: none;
}
.content a{
    text-decoration: none;
    color: #b0b0b0;
    font-size: 12px;
}
.content a:hover{
    color: white;
}
.header-left{
    float: left;
}
.header-right{
    float: right;
}
.header-left-ul>li{
    float: left;
}
.header-right-ul>li{
    float: left;
}
.content li span{
    color: #424242;
    margin: 0 6px;
}
.shop-li{
    background-color: #424242;
    margin-left: 25px;
    width: 120px;
    height: 40px;
    position: relative;
}
.shop-li i{
    margin-right: 4px;
}
.shop-li:hover{
    background-color: white;
    cursor: pointer;
}
.shop-li:hover>a>font{
    color: coral;
}
/* 頭部下拉設定 */

.header-download{
    position: relative;

}
.header-download-div{
    position: absolute;
    top: 40px;
    left: 50%;
    margin-left: -62px;
    width: 124px;
    height: 0;
    overflow: hidden;
    background-color: white;
    box-shadow: 0px 1px  5px #aaa;
    transition: all .3s;
}
.header-download-div img{
    width: 90px;
    height: 90px;
    margin: 18px auto 12px;
    display: block;

}
.header-download-div span{
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    display: block;
    padding-bottom: 10px;
}
.header-download:hover >.header-download-div{
    height: 150px;
}
/* 購物車顯示 */
.shop-div{
    position: absolute;
    right: 0px;
    top:40px;
    width: 316px;
    height: 0;
    background-color: white;
    box-shadow: 0px 2px 10px rgba(0, 0, 0, .15);
    text-align: center;
    line-height: 80px;
    overflow: hidden;
    transition: all .3s;
}
.shop-li:hover >a> .shop-div{
    height: 80px;
}

4、問題

1、懸浮到購物車文字上時,文字自動變為白色,在頁面中檢視原始碼多出了font需要設定在a後面

2、左右兩邊都有資料時,需要設定兩個div包裹起來使用float定位分別設定left和right,裡面的資料在設定為float:left浮動,如果不設定兩個div直接對資料設定左右浮動那麼右側資料將會反過來

3、購物車圖片是引入進來的程式碼如下,透過class設定iconfont來引用

@font-face {font-family: "iconfont";
  src: url('iconfont.eot?t=1548064192113'); /* IE9 */
  src: url('iconfont.eot?t=1548064192113#iefix') format('embedded-opentype'), /* IE6-IE8 */
  url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAA+gAAsAAAAAG3AAAA9QAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCFfgqkbJ1pATYCJANcCzAABCAFhG0HgjIb8xYz0lHSygnZ/yGBGzKhPtSXQUK0JdFIprZadjSVfSM10vjmWFwKGx5fLFiwy1dQ6Ofu322244ZjhlJeT3P+vnsXu4vcxQmaVNBSJFSCBUhCNWJQ0WlSpSZQCRVTpBpqaul36v4hCG/3+xVwogs4wTgKLcKEA31JYAHQ5ucD/zd1VsAHvt3DVKL1acf1Q7ItO4lSRyoNvdvrBWm7u1CNwHgVxWYikZrI3e9l8wjSepyqAG8ukUkNEEQ8AziY3P/fWmqBi3uvwoRKLExelaxRM4fzd//27YQnxBOeCxZRMQhZy3sbgk2KpIBV6sjWmRqpC6lrHMSvYV23RFSD4daOWcEsLJw8z7qtewMEgBIlCTo+3pAAH4nqCF1uXLUE8LlspMSD8DdwBaN2hOZa8Nu0dhnAHPbn0Q978AEInAR6X/brxeXAWNwyFpj4zJke9wQATOwAMIAkAOTELKH1J2Cg1TyM2rjbDaIw5PHFxaUSTSdRrrZcivnVxJRexi+LVaTGy9ZmHUV7SgUSZcTqUhtKkJSY7CX/mYeJiCmRKDQ5IT4FFg8HQYBLRoIhBWgF0lkIANCGJiWo5e6XAQRqFcsABrVKDiKgChzEwGjoANSBAwmMBwcKmAAONDARHOTAbHAQAnPAgQ/MBQcFsA04sMC24MADusCBAywCBwJYDA4CoB86xAdrsAzIwFOGg4RhOnQwYwYKQYoaquMoyQA6AM4HeC+Ym5kk8REkHsciLyTCw148XAQ1bzyQqH5jIcUh6RARIkYoIE1DgTBCygi1O0jYyAh1mFTNikYDI0lDIqNeTEplDEkUTYoeLDqpRSQp0N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vGZh/xehXhYEEV9lj5RsvMf4JrVUGo9aHOYy9D582ukLWrohver0ZY9xCIvL5kejAQAAAA==') format('woff2'),
  url('iconfont.woff?t=1548064192113') format('woff'),
  url('iconfont.ttf?t=1548064192113') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
  url('iconfont.svg?t=1548064192113#iconfont') format('svg'); /* iOS 4.1- */
}

.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-15tianwuliyoutuihuo:before {
  content: "\e606";
}

.icon-liwu:before {
  content: "\e657";
}

.icon-iconfonticon5:before {
  content: "\e615";
}

.icon-shouji01:before {
  content: "\e622";
}

.icon-gouwuche:before {
  content: "\e653";
}

.icon-icon:before {
  content: "\e666";
}

.icon-zhizhen:before {
  content: "\e64d";
}

.icon-jiantou2:before {
  content: "\e63e";
}

.icon-youjiantou:before {
  content: "\e658";
}

.icon-buoumaotubiao46:before {
  content: "\e629";
}

.icon-jiantouyou:before {
  content: "\e62a";
}

.icon-fangdajing:before {
  content: "\e63d";
}

.icon-jiantou:before {
  content: "\e616";
}

.icon-jiantou_zuo:before {
  content: "\e617";
}

.icon-duihua:before {
  content: "\e710";
}

.icon-dianhuaqia:before {
  content: "\e733";
}

.icon-chongzhijilu:before {
  content: "\e64c";
}

.icon-gouwuche1:before {
  content: "\e735";
}

.icon-kefu:before {
  content: "\e6ab";
}

.icon-liwu1:before {
  content: "\e62b";
}

.icon-qitianwuliyoutuihuan:before {
  content: "\e63f";
}

.icon-F:before {
  content: "\e61f";
}

二、

相關文章