老师您好,麻烦看下有什么需要改进的?

来源:4-4 自由编程

goonight

2020-11-11 17:03:23

# 具体遇到的问题

# 报错信息的截图

# 相关课程内容截图

# 尝试过的解决思路和结果

# 粘贴全部相关代码,切记添加代码注释(请勿截图)

在这里输入代码,可通过选择【代码语言】突出显示

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



*{

    margin: 0;

    padding: 0;

}

/* 去掉ul的小圆点 */

ul{

    list-style: none;


}

/* 去掉所有超级链接下划线 */

a{

    text-decoration: none;

}

header .header-top {

    width: 100%;

    height: 80px;

    background-color: #07cbc9;

}

header .header-top .logo {

    float: left;

    position: absolute;

    top: 22px;

    left: 220px;

    height: 48px;

    margin: 0 auto;

    text-align: center;

    font-family: 'Broadway';

    color: aliceblue;

    /* 设置触碰时候的鼠标指针的样式 */

    cursor: pointer;

    

}

header .header-top .nav {

    position: absolute;

    top: 6px;

    right: 220px;

}

header .header-top .nav ul {

    width: 600px;

    height: 80px;

    margin: 0 auto;

    /* 设置触碰时候的鼠标指针的样式 */

    cursor: pointer;

}

header .header-top .nav ul li {

    float: left;

    text-align: center;

    margin-right: 20px;

    line-height: 80px;

    

}


header .header-top .nav ul li a {

    font-size: 16px

    color: aliceblue;

    font-family: 'Berlin Sans FB';

}




<!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="icon" href="images/icon.ico">

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

</head>

<body>

    <header>

        <div class="header-top">

            <div class="logo">

                <h1>Career Builder</h1>

            </div>

            <div class="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>

            </div>

        </div>

    </header>

</body>

</html>



写回答

1回答

好帮手慕鹤

2020-11-11

同学你好,实现效果的代码写的有些复杂,可以参考老师的建议来进行优化:

(1)最外层header设置宽度为100%,设置背景颜色为#07cbc9;

(2)类名叫header-top的容器设置宽度为1200px,通过margin:0 auto;实现水平居中的效果。

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

(3)左侧logo图和右侧导航项,可以直接使用浮动来实现同一行显示的样式,不需要再添加定位来调整位置。

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

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

修改之后的css代码:

​ * {

margin: 0;

padding: 0;

}
/* 去掉ul的小圆点 */
ul {
list-style: none;
}
/* 去掉所有超级链接下划线 */
a {
text-decoration: none;
}
header {
width: 100%;
background-color: #07cbc9;

}
header .header-top {
width: 1200px;
margin: 0 auto;
height: 80px;
}

header .header-top .logo {
float: left;
height: 36px;
text-align: center;
font-family: 'Broadway';
color: aliceblue;
cursor: pointer;
line-height: 80px;
}

header .header-top .nav ul {
width: 500px;
height: 80px;
cursor: pointer;
float: right;
}

header .header-top .nav ul li {
float: left;
text-align: center;
margin-right: 20px;
line-height: 80px;
}

header .header-top .nav ul li a {
font-size: 16px;
color: aliceblue;
font-family: 'Berlin Sans FB';
}

祝学习愉快!

0

0 学习 · 15276 问题

查看课程