2022年11月23日14:23:00—H5—T7-T8(布局与内容填充)

举报
红目香薰 发表于 2022/11/29 15:28:43 2022/11/29
【摘要】 ​ ​编辑Base.css* {    margin: 0px;    padding: 0px;    box-sizing: border-box;}ul {    list-style: none;}.col-1 {    width: 8.33%;    float: left;}.col-2 {    width: 16.66%;    float: left;}.col-3 { ...

 编辑

Base.css

* {

    margin: 0px;

    padding: 0px;

    box-sizing: border-box;

}


ul {

    list-style: none;

}


.col-1 {

    width: 8.33%;

    float: left;

}


.col-2 {

    width: 16.66%;

    float: left;

}


.col-3 {

    width: 25%;

    float: left;

}


.col-4 {

    width: 33.33%;

    float: left;

}


.col-5 {

    width: 41.66%;

    float: left;

}


.col-6 {

    width: 50%;

    float: left;

}


.col-7 {

    width: 58.33%;

    float: left;

}


.col-8 {

    width: 66.66%;

    float: left;

}


.col-9 {

    width: 75%;

    float: left;

}


.col-10 {

    width: 83.33%;

    float: left;

}


.col-11 {

    width: 91.66%;

    float: left;

}


.col-12 {

    width: 100%;

    float: left;

}

示例:基本框架的创建

<!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>Document</title>
    <link rel="stylesheet" href="css/base.css">
</head>

<body>
    <!-- 开始填充文字 -->
    <div id="top" class="col-12" style="background-color: #3C3E3B;height: 10vh;">
        <style>
            .top_left_text {
                text-align: center;
                line-height: 10vh;
                font-size: 1.2rem;
                font-weight: bolder;
            }
        </style>
        <div class="col-2 top_left_text" style="background-color: pink;height: 10vh;">
            <span>游戏商城</span>
        </div>
        <div class="col-7" style="background-color: skyblue;height: 10vh;">
            <style>
                .top_center_ul {
                    width: 100%;
                }
                
                .top_center_ul li {
                    width: 25%;
                    float: left;
                    text-align: center;
                    line-height: 10vh;
                }
                
                .top_center_ul li:hover {
                    background-color: black;
                    color: white;
                    cursor: pointer;
                }
            </style>
            <ul class="top_center_ul">
                <li>商店</li>
                <li>关于</li>
                <li>社区</li>
                <li>支持</li>
            </ul>
        </div>
        <div class="col-3" style="background-color: red;height: 10vh;">
            <style>
                .top_right_ul {
                    background-color: black;
                    height: 8vh;
                    border-radius: 0px 0px 30% 30%;
                }
                
                .top_right_ul li {
                    width: 33.33%;
                    line-height: 8vh;
                    color: white;
                    float: left;
                    text-align: center;
                }
                
                .top_right_ul li:hover {
                    background-color: gray;
                }
            </style>
            <ul class="top_right_ul" style="width: 100%;">
                <li>登录</li>
                <li>注册</li>
                <li>搜索</li>
            </ul>
        </div>
    </div>
    <div class="col-12" style="height: 5vh;">
        <div class="col-1" style="height: 5vh;"></div>
        <div class="col-10" style="height: 5vh;">新鲜事情</div>
        <div class="col-1" style="height: 5vh;"></div>
    </div>
    <div class="col-12" style="height: 50vh;">
        <div class="col-1" style="height: 50vh;"></div>
        <style>
            .banner-img {
                height: 50vh;
                background-color: skyblue;
                border-radius: 12px;
                box-shadow: 5px 5px 5px 5px gray;
            }
        </style>
        <div class="col-10 banner-img"></div>
        <div class="col-1" style="height: 50vh;"></div>
    </div>
</body>

</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">
    <title>Document</title>
    <link rel="stylesheet" href="css/base.css">
</head>

<body>
    <!-- top完毕 -->
    <div class="col-12" style="height: 10vh;background-color: #3D3E3B;">
        <style>
            .top_left_text {
                text-align: center;
                font-size: 1.5rem;
                font-weight: bolder;
                color: white;
                line-height: 10vh;
            }
        </style>
        <div class="col-2 top_left_text" style="height: 10vh;">
            游戏商城
        </div>
        <div class="col-7" style="height: 10vh;">
            <style>
                .top_center_ul {
                    width: 100%;
                }
                
                .top_center_ul li {
                    width: 25%;
                    float: left;
                    text-align: center;
                    line-height: 10vh;
                    color: white;
                    cursor: pointer;
                    /* 鼠标变手 */
                }
            </style>
            <ul class="top_center_ul">
                <li>宫廷玉叶酒</li>
                <li>霸王别鸡</li>
                <li>干锅咕咾肉</li>
                <li>佛跳跳</li>
            </ul>
        </div>
        <div class="col-3" style="height: 10vh;">
            <style>
                .top_right_ul {
                    width: 100%;
                    background-color: black;
                    height: 5vh;
                    border-radius: 0px 0px 100px 100px;
                }
                
                .top_right_ul li {
                    width: 33.33%;
                    float: left;
                    text-align: center;
                    color: white;
                    cursor: pointer;
                }
            </style>
            <ul class="top_right_ul">
                <li>登录</li>
                <li>注册</li>
                <li>搜索</li>
            </ul>
        </div>
    </div>
    <!-- banner_text -->
    <div class="col-12">
        <div class="col-2" style="height: 5vh;"></div>
        <div class="col-7" style="height: 5vh;">新鲜事</div>
        <div class="col-3" style="height: 5vh;"></div>
    </div>
    <!-- banner_2 -->
    <div class="col-12">
        <div class="col-2" style="height: 50vh;"></div>
        <style>
            .banner_2_img {
                height: 50vh;
                background-image: url('imgs/bg.jpg');
                background-size: 100% 100%;
            }
            
            .banner_2_img_button {
                position: relative;
                left: 85%;
                top: 85%;
            }
        </style>
        <div class="col-8 banner_2_img">
            <button class="banner_2_img_button">¥699.99元</button>
        </div>
        <div class="col-2" style="height: 50vh;"></div>
    </div>
</body>

</html>

编辑这里每个盒子都要处理好对应的高度比例。

【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。