前端基础之小米网页编写(基础)

之前犯了没有规划布局的错,版排丑陋、问题一堆,以至于满盘皆输、从头来过,所以重新返工的我老老实实从规划布局开始,观察小米官网,发现其首页可看做四个长方形大盒子排排站,每一个大盒子里又可分为若干小盒子,小盒子里又可嵌套小小盒子……盒子盒子无穷尽也。

html中关于box的类定义真的很多,定义时一定要分清,略作归类区别,以免后期太多混淆。

轮播:

Bootstrap官网→v4→快速入门→组件→轮播

Bootstrap 是全球最受欢迎的前端开源工具库,它支持 Sass 变量和 mixin、响应式栅格系统、自带大量组件和众多强大的 JavaScript 插件。基于 Bootstrap 提供的强大功能,能够让你快速设计并定制你的网站。

里面有运行的实例和代码可以引用学习。

关于轮播时间间隔:

在想要安排时间间隔的代码总的div里加入data-interval="3000","(单位:毫秒,一般是x000,可以是1000ms=1s)"

运行代码:

<!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">
    <title>是小米鸭(终)</title>

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.min.js" integrity="sha384-VHvPCCyXqtD5DqJeNxl2dtTyhF78xXNXdkwX1CZeRusQfRKp+tA7hAShOK/B/fQ2" crossorigin="anonymous"></script>


    <style>
        .box {
            width: 1500px;
            height: 750px;
            align-content: center;
        }
        
        .box1 {
            width: 1500px;
            height: 30px;
            background-color: rgb(8, 8, 8);
        }
        
        .box11 {
            height: 28px;
            margin-left: 5px;
            margin-right: 5px;
            margin-top: 4px;
            /* float: left; */
            overflow: hidden;
            text-align: center;
            color: ghostwhite;
            font-size: small;
            line-height: 20px;
            display: inline-block;
        }
        
        .box12 {
            height: 28px;
            margin-left: 5px;
            margin-right: 5px;
            margin-top: 4px;
            float: right;
            overflow: hidden;
            text-align: center;
            color: ghostwhite;
            font-size: small;
            line-height: 20px;
            display: inline-block;
        }
        
        .box2 {
            width: 1500px;
            height: 100px;
            background-color: white;
        }
        
        .box21 {
            width: 100px;
            height: 50px;
            float: left;
            margin-top: 35px;
            margin-left: 5px;
        }
        
        .box22 {
            /* background-color: white; */
            position: relative;
            width: 20px;
            height: 20px;
            top: 0px;
            left: 2px;
        }
        
        #box22:hover {
            background-color: orange;
            /* cursor: pointer; */
        }
        
        #box22:hover img {
            content: url("./搜索.png");
        }
        
        .box3 {
            width: 1500px;
            height: 400px;
            margin-left: 5%;
        }
        
        .box31 {
            width: 250px;
            height: 400px;
            float: left;
            background-color: grey;
        }
        
        .box311 {
            width: 250px;
            height: 40px;
            float: left;
            color: white;
            /* border: 1px solid red; */
            /* text-align: center; */
            line-height: 40px;
            padding-left: 20px;
        }
        
        .box311 img {
            height: 20px;
            width: 20px;
            float: right;
            position: relative;
            left: -20px;
            top: 6px;
        }
        
        .box311:hover {
            background-color: orange;
        }
        
        .box32 {
            width: 950px;
            height: 400px;
            float: left;
            position: relative;
            /* left: 50px; */
        }
        
        .box33 {
            width: 300px;
            height: 400px;
            float: left;
        }
        
        .box331 {
            margin-top: 20px;
        }
        
        .box332:hover {
            content: url("收款.png");
            width: 250px;
            height: 250px;
            /* position: absolute;
            margin-top: 50px;
            margin-left: 900px; */
        }
        
        .box333:hover {
            content: url("收款.png");
            width: 250px;
            height: 250px;
        }
        /* .box333 {
            background-color: white;
        } */
        
        .box334:hover {
            content: url("收款.png");
            width: 250px;
            height: 250px;
        }
        
        .box335:hover {
            content: url("收款.png");
            width: 250px;
            height: 250px;
        }
        
        .box336:hover {
            content: url("收款.png");
            width: 250px;
            height: 250px;
        }
        
        .box4 {
            width: 1500px;
            height: 200px;
            margin-left: 5%;
        }
        
        .box41 {
            width: 240px;
            height: 200px;
            background-color: black;
            font-size: 10px;
            margin-left: 0px;
            float: left;
        }
        
        .box411 {
            width: 80px;
            height: 50px;
            float: left;
            position: relative;
            top: 50px;
            left: 20px;
        }
        
        .box42 {
            width: 300px;
            height: 200px;
            margin-left: 20px;
            float: left;
        }
        
        .box43 {
            width: 300px;
            height: 200px;
            margin-left: 20px;
            float: left;
        }
        
        .box44 {
            width: 300px;
            height: 200px;
            margin-left: 20px;
            float: left;
        }
    </style>
</head>

<body>
    <div class="box">

        <div class="box1">
            <span class="box11">小米商城&nbsp;|</span>
            <span class="box11">MIUI&nbsp;|</span>
            <span class="box11">IoT&nbsp;|</span>
            <span class="box11">云服务&nbsp;|</span>
            <span class="box11">天星数科&nbsp;|</span>
            <span class="box11">有品&nbsp;|</span>
            <span class="box11">小爱开放平台&nbsp;|</span>
            <span class="box11">企业团购&nbsp;|</span>
            <span class="box11">资质证照&nbsp;|</span>
            <span class="box11">协议规则&nbsp;|</span>
            <span class="box11">下载app&nbsp;|</span>
            <span class="box11">智能生活&nbsp;|</span>
            <span class="box11">Select Location&nbsp;|</span>


            <span class="box12">购物车(0)</span>
            <img class="box12" src="F:/VS Code相关/小米网页/购物车空.png" width="28" height="28"></img>
            <span class="box12">消息通知&nbsp;|</span>
            <span class="box12">注册&nbsp;|</span>
            <span class="box12">登录&nbsp;|</span>
        </div>
        <div class="box2">
            <img src="F:/VS Code相关/小米网页/mi.png" style="position: absolute;width: 85px;height:85px;top: 40px;left: 70px;">

            <div class="box21" style="margin-left: 250px;">Xiaomi手机</div>
            <div class="box21">Redmi 红米</div>
            <div class="box21">电视</div>
            <div class="box21">笔记本</div>
            <div class="box21">平板</div>
            <div class="box21">家电</div>
            <div class="box21">路由器</div>
            <div class="box21">服务</div>
            <div class="box21">社区</div>

            <form action="" style="position:relative;left: 50px;top: 35px;">
                <input type="select" placeholder="请输入搜索内容">
                <span id="box22"><img class="box22" src="./搜索小.png" style=""></span>
            </form>
        </div>

        <div class="box3">
            <div class="box31">
                <div class="box311" style="margin-top: 5px;">手机
                    <img src="F:/VS Code相关/小米网页/右箭头.png" alt="">
                </div>
                <div class="box311">电视
                    <img src="F:/VS Code相关/小米网页/右箭头.png" alt="">
                </div>
                <div class="box311">笔记本 平板
                    <img src="F:/VS Code相关/小米网页/右箭头.png" alt="">
                </div>
                <div class="box311">家电
                    <img src="F:/VS Code相关/小米网页/右箭头.png" alt="">
                </div>
                <div class="box311">出行 穿戴
                    <img src="F:/VS Code相关/小米网页/右箭头.png" alt="">
                </div>
                <div class="box311">智能 路由器
                    <img src="F:/VS Code相关/小米网页/右箭头.png" alt="">
                </div>
                <div class="box311">电源 配件
                    <img src="F:/VS Code相关/小米网页/右箭头.png" alt="">
                </div>
                <div class="box311">健康 儿童
                    <img src="F:/VS Code相关/小米网页/右箭头.png" alt="">
                </div>
                <div class="box311">耳机 音响
                    <img src="F:/VS Code相关/小米网页/右箭头.png" alt="">
                </div>
                <div class="box311">生活 箱包
                    <img src="F:/VS Code相关/小米网页/右箭头.png" alt="">
                </div>
            </div>

            <div class="box32">
                <!-- <img src="F:/VS Code相关/小米网页/1.jpg" " alt=" " style="width: 1150px;height: 600px; "> -->

                <div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel" data-interval="3000">
                    <ol class="carousel-indicators">
                        <li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
                        <li data-target="#carouselExampleCaptions" data-slide-to="1"></li>
                        <li data-target="#carouselExampleCaptions" data-slide-to="2"></li>
                        <li data-target="#carouselExampleCaptions" data-slide-to="3"></li>
                    </ol>
                    <div class="carousel-inner">
                        <div class="carousel-item active">
                            <img src="F:/VS Code相关/小米网页/1.jpg" class="d-block w-100" alt="..." style="height: 400px;width: 1150px;">
                            <div class="carousel-caption d-none d-md-block">
                                <h5>First slide label</h5>
                                <p>Some representative placeholder content for the first slide.</p>
                            </div>
                        </div>
                        <div class="carousel-item">
                            <img src="F:/VS Code相关/小米网页/11.jpg" class="d-block w-100" alt="..." style="height: 400px;width: 1150px;">

                            <div class="carousel-caption d-none d-md-block">
                                <h5>Second slide label</h5>
                                <p>Some representative placeholder content for the second slide.</p>
                            </div>
                        </div>
                        <div class="carousel-item">
                            <img src="F:/VS Code相关/小米网页/111.jpg" class="d-block w-100" alt="..." style="height: 400px;width: 1150px;">
                            <div class="carousel-caption d-none d-md-block">
                                <h5>Third slide label</h5>
                                <p>Some representative placeholder content for the third slide.</p>
                            </div>
                        </div>
                        <div class="carousel-item">
                            <img src="F:/VS Code相关/小米网页/1111.jpg" class="d-block w-100" alt="..." style="height: 400px;width: 1150px;">
                            <div class="carousel-caption d-none d-md-block">
                                <h5>Third slide label</h5>
                                <p>Some representative placeholder content for the third slide.</p>
                            </div>
                        </div>
                    </div>
                    <button class="carousel-control-prev" type="button" data-target="#carouselExampleCaptions" data-slide="prev">
                  <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                  <span class="sr-only">Previous</span>
                </button>
                    <button class="carousel-control-next" type="button" data-target="#carouselExampleCaptions" data-slide="next">
                  <span class="carousel-control-next-icon" aria-hidden="true"></span>
                  <span class="sr-only">Next</span>
                </button>
                </div>

            </div>

            <div class="box33 ">
                <div class="box331 ">
                    <div class="box332 ">
                        <img src="F:/VS Code相关/小米网页/手机.png " alt=" " style="width:70px;height: 70px; ">
                        <div style="color: gray; ">手机APP</div>
                        <!-- <div>
                        <img src="F:/VS Code相关/小米网页/收款.png" alt="" style="position: absolute;margin-top: -100px;margin-left: -400px;">
                    </div> -->
                    </div>
                    <div class="box333 ">
                        <img src="F:/VS Code相关/小米网页/用户.png " alt=" " style="width:70px;height: 70px; ">
                        <div style="color: gray; ">个人中心</div>
                    </div>
                    <div class="box334 ">
                        <img src="F:/VS Code相关/小米网页/我的-售后.png " alt=" " style="width: 70px;height: 70px; ">
                        <div style="color: gray; ">售后服务</div>
                    </div>
                    <div class="box335 ">
                        <img src="F:/VS Code相关/小米网页/人工客服.png " alt=" " style="width: 70px;height: 70px; ">
                        <div style="color: gray; ">人工客服</div>
                    </div>
                    <div class="box336 ">
                        <img src="F:/VS Code相关/小米网页/购物车.png " alt=" " style="width: 70px;height: 70px; ">
                        <div style="color: gray; ">购物车</div>
                    </div>
                </div>
            </div>
        </div>

        <div class="box4 ">
            <div class="box41 ">
                <div class="box411 ">
                    <img src="F:/VS Code相关/小米网页/时间.png " alt=" " style="width: 30px;height: 30px; ">
                    <div style="color: gray; ">保障服务</div>
                </div>
                <div class="box411 ">
                    <img src="F:/VS Code相关/小米网页/企业.png " alt=" " style="width: 30px;height: 30px; ">
                    <div style="color: gray; ">企业团购</div>
                </div>
                <div class="box411 ">
                    <img src="F:/VS Code相关/小米网页/F码.png " alt=" " style="width: 30px;height: 30px; ">
                    <div style="color: gray; ">F码通道</div>
                </div>
                <div class="box411 ">
                    <img src="F:/VS Code相关/小米网页/内存卡.png " alt=" " style="width: 30px;height: 30px; ">
                    <div style="color: gray; ">米粉卡</div>
                </div>
                <div class="box411 ">
                    <img src="F:/VS Code相关/小米网页/付款.png " alt=" " style="width: 30px;height: 30px; ">
                    <div style="color: gray; ">以旧换新</div>
                </div>
                <div class="box411 ">
                    <img src="F:/VS Code相关/小米网页/话费.png " alt=" " style="width: 30px;height: 30px; ">
                    <div style="color: gray; ">话费充值</div>
                </div>
            </div>
            <div class="box42 ">
                <img src="F:/VS Code相关/小米网页/2.jpg " alt=" " style="width: 300px;height: 200px; ">
            </div>
            <div class="box43 ">
                <img src="F:/VS Code相关/小米网页/3.jpg " alt=" " style="width: 300px;height: 200px; ">
            </div>
            <div class="box44 ">
                <img src="F:/VS Code相关/小米网页/4.jpg " alt=" " style="width: 300px;height: 200px; ">
            </div>
        </div>

    </div>

</body>

</html>

成品展示:

 

中途产生了很多错误和小瑕疵,幸亏有高尚老师和友友们帮助解惑,十分感谢大家呀!

谢谢大家不离不弃,不嫌弃我这个人形bug制造机,耐心解答帮助我,啾咪~

私心藏了个彩蛋,扫码即可向我转账O(∩_∩)O

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值