请老师帮忙检查代码的规范性,并解决一个疑惑

来源:2-17 自由编程

hehe纷扬

2020-11-29 20:34:32

HTML部分如下:

<!DOCTYPE html>

<html lang="en">


<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Career Builder</title>

    <link rel="stylesheet" href="css/css.css">

</head>


<body>

    <!-- 页面头部 -->

    <header>

        <div class="content">

            <!-- 网页的logo -->

            <div class="logo">

                <img src="images/logo.png" alt="">

            </div>


            <!-- 导航条 -->

            <nav>

                <ul>

                    <li><a href="">HOME</a></li>

                    <li><a href="">ABOUT</a></li>

                    <li><a href="">GALLERY</a></li>

                    <li><a href="">FACULTY</a></li>

                    <li><a href="">EVENTS</a></li>

                    <li><a href="">CONTACT</a></li>

                </ul>

            </nav>

        </div>

    </header>


    <!-- 页面Banner -->

    <section class="banner">

        <!-- 图片 -->

        <img src="images/banner3.jpg" alt="">


        <!-- 遮罩层 -->

        <div class="layer">banner遮罩层</div>


        <!-- 表单 -->

        <form action="">

            <input type="text" placeholder="your Name"><br>

            <input type="text" placeholder="your Phone"><br>

            <input type="email" placeholder="your Email"><br>

            <textarea placeholder="Write Your Comment Here" cols="40" rows="5"></textarea><br>

            <input type="submit" value="SEND MESSAGE">

        </form>

    </section>


    <!-- 页面的主要内容 -->

    <section class="content">

        <!-- About区域 -->

        <div class="about">

            <!-- 标题 -->

            <h2>ABOUT</h2>


            <!-- 分割线 -->

            <span class="separator"></span>


            <!-- 简短描述 -->

            <div class="desc-lite">

                <p>Lorem Ipsum is simply dummy text of the printing and typesetting<br> industry. Lorem Ipsum has been

                    the

                    industry's standard dummy<br> text ever since the 1500s.</p>

            </div>


            <!-- 详细内容的盒子 -->

            <div class="desc-box">

                <!-- 左侧文字 -->

                <div class="left">

                    <h3>A WORD<br>ABOUT US</h3>

                    <!-- 详细描述 -->

                    <div class="desc-full">

                        <p>Praesent dignissim viverra est, sed bibendum ligula congue non. Sed ac nisl et felis gravida

                            commodo?

                            Suspendisse eget ullamcorper ipsum. Suspendisse diam amet.</p>

                        <p class="btn">EXPLORE</p>

                    </div>

                </div>


                <!-- 中间的图片 -->

                <img src="images/bb3.jpg" alt="">


                <!-- 右侧数量 -->

                <div class="right">

                    <div class="box">

                        <p class="num">7000000</p>

                        <!-- 分割线 -->

                        <span class="separator"></span>

                        <p>Students</p>

                    </div>

                    <div class="box">

                        <p class="num">600</p>

                        <!-- 分割线 -->

                        <span class="separator"></span>

                        <p>Faculty</p>

                    </div>

                </div>

            </div>

        </div>


        <!-- 图文混排区域 -->

        <div class="pic-word-mix">

            <img src="images/b1.jpg" alt="">

            <div class="word arrow-left">

                <h3>Library</h3>

                <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>

                <p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer

                    took a galley of type and scrambled it to make a type specimen book.</p>

                <p>EXPLORE</p>

            </div>

            <img src="images/b2.jpg" alt="">

            <div class="word arrow-left">

                <h3>Library</h3>

                <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>

                <p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer

                    took a galley of type and scrambled it to make a type specimen book.</p>

                <p>EXPLORE</p>

            </div>

            <div class="word arrow-right">

                <h3>Library</h3>

                <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>

                <p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer

                    took a galley of type and scrambled it to make a type specimen book.</p>

                <p>EXPLORE</p>

            </div>

            <img src="images/b3.jpg" alt="">

            <div class="word arrow-right">

                <h3>Library</h3>

                <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>

                <p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer

                    took a galley of type and scrambled it to make a type specimen book.</p>

                <p>EXPLORE</p>

            </div>

            <img src="images/b4.jpg" alt="">

        </div>


        <!-- Gallery区域 -->

        <div class="gallery">

            <!-- 标题 -->

            <h2>GALLERY</h2>


            <!-- 分割线 -->

            <span class="separator"></span>


            <!-- 简短描述 -->

            <div class="desc-lite">

                <p>Lorem Ipsum is simply dummy text of the printing and typesetting<br> industry. Lorem Ipsum has been

                    the

                    industry's standard dummy<br> text ever since the 1500s.</p>

            </div>


            <!-- 详细描述 -->

            <div class="desc-full">

                <ul>

                    <li>

                        <dl>

                            <dt>

                                <img src="images/03-01.jpg" alt="">

                            </dt>

                            <dd>Science Lab</dd>

                        </dl>

                    </li>

                    <li>

                        <dl>

                            <dt>

                                <img src="images/03-02.jpg" alt="">

                            </dt>

                            <dd>Indoor Stadium</dd>

                        </dl>

                    </li>

                    <li>

                        <dl>

                            <dt>

                                <img src="images/03-03.jpg" alt="">

                            </dt>

                            <dd>Transportation</dd>

                        </dl>

                    </li>

                    <li>

                        <dl>

                            <dt>

                                <img src="images/03-04.jpg" alt="">

                            </dt>

                            <dd>Kids Room</dd>

                        </dl>

                    </li>

                    <li>

                        <dl>

                            <dt>

                                <img src="images/03-05.jpg" alt="">

                            </dt>

                            <dd>Meditation Classes</dd>

                        </dl>

                    </li>

                    <li>

                        <dl>

                            <dt>

                                <img src="images/03-06.jpg" alt="">

                            </dt>

                            <dd>Kids Play Ground</dd>

                        </dl>

                    </li>

                </ul>

            </div>

        </div>

    </section>


    <!-- 页脚 -->

    <footer>

        <p>&copy; 2016 imooc.com 京ICP备13046642号</p>

    </footer>

</body>


</html>

CSS部分:

/* 清除默认样式 */

* {

    padding0;

    margin0;

}


ulol {

    list-stylenone;

}


a {

    text-decorationnone;

}


/* 分割线 */

.separator {

    /* 将span转换为块级元素 */

    displayblock;

    width60px;

    height3px;

    background#07cbc9;

    margin10px auto;

}


/* 顶部样式 */

header {

    height80px;

    background-color#07cbc9;

}


header .content {

    width1200px;

    margin0 auto;

}


header .content .logo {

    floatleft;

    margin-top16px;

}


header .content nav {

    floatright;

}


header .content nav ul li {

    floatleft;

}


header .content nav ul li a {

    displayblock;

    color#fff;

    line-height80px;

    margin-right20px;

}


/* banner区域 */

.banner {

    width100%;

    height600px;

    positionrelative;

}


.banner img {

    width100%;

    height600px;

}


.banner .layer {

    width100%;

    height600px;

    positionabsolute;

    top0;

    left0;

    background:rgba(0000.5);

}


.banner form {

    positionabsolute;

    left50%;

    top100px;

    width504px;

    margin-left-252px;

    text-aligncenter;

}


.banner form input {

    width504px;

    height40px;

    box-sizingborder-box;

    margin-bottom20px;

    backgroundnone;

    color#808080;

    border2px solid #808080;

}


.banner form input[type='submit'] {

    width200px;

    height40px;

    margin-bottom0;

}


.banner form textarea {

    width504px;

    height110px;

    box-sizingborder-box;

    margin-bottom20px;

    backgroundnone;

    border2px solid #808080;

}


/* 页面主要内容区域 */

.content {

    margin30px 0;

}


.content .about {

    width1200px;

    margin0 auto;

}


.content .about h2 {

    font-size32px;

    text-aligncenter;

}


.content .about .desc-lite {

    text-aligncenter;

    colorgray;

    font-size14px;

}


.content .about .desc-box {

    width1201px;

    height464px;

    /* 相对定位 */

    positionrelative;

    margin-top30px;

}


.content .about .desc-box .left {

    floatleft;

    /* 绝对定位 */

    positionabsolute;

    z-index999;

}


.content .about .desc-box .left h3 {

    font-size28px;

    line-height40px;

    margin-bottom20px;

}


.content .about .desc-box .left .desc-full {

    width300px;

    padding20px;

    font-size18px;

    border1px solid gray;

    backgroundrgba(2552552550.5);

}


.content .about .desc-box .desc-full .btn {

    width140px;

    height40px;

    background#000;

    color#fff;

    text-aligncenter;

    line-height40px;

    margin-top25px;

}


.content .about .desc-box img {

    width650px;

    height435px;

    floatleft;

    positionabsolute;

    top0;

    left50%;

    margin-left-325px;

}


.content .about .desc-box .right {

    floatright;

    text-aligncenter;

}


.content .about .desc-box .right .box {

    padding40px 60px;

    border1px solid #07cbc9;

}


.content .about .desc-box .right .box:first-child {

    margin-bottom30px;

}


.content .about .desc-box .right .box .num {

    font-size28px;

    font-weightbold;

}


/* 图文混排区域 */

.content .pic-word-mix {

    width100%;

    height760px;

    background-color#07cbc9;

}


/* 向左的箭头 */

.content .pic-word-mix .arrow-left::before {

    content'';

    displayblock;

    width0;

    height0;

    border20px solid transparent;

    border-right-color#07cbc9;

    positionabsolute;

    left-40px;

    top50%;

    margin-top-20px;

}


/* 向右的箭头 */

.content .pic-word-mix .arrow-right::after {

    content'';

    displayblock;

    width0;

    height0;

    border20px solid transparent;

    border-left-color#07cbc9;

    positionabsolute;

    right-40px;

    top50%;

    margin-top-20px;

}


.content .pic-word-mix img {

    floatleft;

    height380px;

    width25%;

}


.content .pic-word-mix .word {

    floatleft;

    height380px;

    width25%;

    /* 将间距计算在设定的宽度内 */

    box-sizingborder-box;

    padding20px;

    /* 相对定位 */

    positionrelative;

}


.content .pic-word-mix .word h3 {

    font-size24px;

    color#fff;

    margin-bottom30px;

}


.content .pic-word-mix .word p:nth-of-type(1) {

    font-size16px;

    color#fff;

    margin-bottom20px;

}


.content .pic-word-mix .word p:nth-of-type(2) {

    font-size14px;

    colorgray;

    margin-bottom30px;

}


.content .pic-word-mix .word p:nth-of-type(3) {

    width138px;

    height40px;

    color#fff;

    text-aligncenter;

    background-color#000;

    line-height40px;

    margin0 auto;

}


/* gallery区域 */

.content .gallery {

    width1200px;

    margin0 auto;

    margin-top30px;

}


.content .gallery h2 {

    font-size32px;

    text-aligncenter;

}


.content .gallery .desc-lite {

    text-aligncenter;

    colorgray;

    font-size14px;

}


.content .gallery .desc-full {

    width1200px;

    height653px;

    padding20px;

    box-sizingborder-box;

    overflowhidden;

}


.content .gallery .desc-full ul li dl {

    floatleft;

    margin-right40px;

    /* 相对定位 */

    positionrelative;

    margin-bottom30px;

}


.content .gallery .desc-full ul li dd {

    /* 绝对定位 */

    positionabsolute;

    bottom0;

    left0;

    height50px;

    width360px;

    line-height50px;

    color#fff;

    background-color#000;

    padding-left20px;

    box-sizingborder-box;

}


.content .gallery .desc-full ul li:nth-of-type(3dl.content .gallery .desc-full ul li:nth-of-type(6dl {

    margin-right0;


.content .gallery .desc-full ul li dl dt img {

    width360px;

    height290px;

}


/* 页脚 */

footer {

    width100%;

    height80px;

    background-color#07cbc9;

    line-height80px;

    text-aligncenter;

}



另外我还有一个疑惑:为什么浏览器窗口缩放后,页面头部的导航条会被直接截断呢?我看了参考代码好像也存在这个现象

http://img.mukewang.com/climg/5fc393d3095e5cfe06910445.jpg

写回答

1回答

好帮手慕星星

2020-11-30

同学你好,代码实现效果很棒,规范没有问题。

针对提问回复:

出现这种情况水平方向上应该出现了滚动条

http://img.mukewang.com/climg/5fc44ec609cff94708890945.jpg

这是因为顶部设置固定定位,宽度和浏览器视口一致,所以当出现滚动条的时候,滚动条多出的部分并不会延伸,就会有空白显示。

当前可以不考虑视口缩小的情况,能够在100%下显示即可,在后面移动端响应式布局中会有讲解,不要着急哦。

祝学习愉快!

0

0 学习 · 15276 问题

查看课程