老师,麻烦帮我看下哪里需要改进的,还有按钮应该怎么做

来源:4-4 自由编程

大白前端

2020-10-24 22:55:41

# 具体遇到的问题

# 报错信息的截图

# 相关课程内容截图

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

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

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

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title></title>

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

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

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

<style>

.header-container{

width: 100%;

background-color: #fff;

border-bottom: 1px solid #dadada;

}

img{

width: 200px;

}

.header-btn,

.header-nav,

.header-logo{

height: 60px;

}

.header-btn{

display: flex;

align-items: center;

justify-content:flex-start;

background-color: red;

}

.btn{

padding: 5px;

background-color: transparent;

border-radius: 4px;

border: none;

cursor: pointer;

}

.header-line{

display: block;

width: 30px;

height: 3px;

background-color: #fff;

border-radius: 2px;

}

.header-line + .header-line{

margin-top: 4px;

}

.header-logo{

display: flex;

align-items: center;

justify-content: center;

}

.header-link,

.header-item,

.header-item-i

{

height: 100%;

}

.header-link{

display: flex;

align-items: center;

justify-content: flex-start;

font-size: 14px;

}

.header-item{

margin-right: 24px;

}

.header-item:lase-child{

margin-right: 0;

}

.header-item-i{

display: flex;

align-items: center;

font-weight: bold;

}

.nav-contents{

overflow: hidden;

position: relative;

top: -1px;

height: 0;

border-bottom: 1px solid #dadada;

transition: height 1s;

}

.nav-content-extended{

top: 0;

height: 121px;

}

.nav-content{

display: block;

height: 40px;

line-height: 40px;

font-weight: bold;

}

</style>

</head>

<body>

<div class="header-container">

<div class="container">

<div class="row">

<div class="header-btn col-2 d-md-none">

<button type="button" class="btn" id="truggle">

<span class="header-line"></span>

<span class="header-line"></span>

</button>

</div>

<div class="header-nav col-md-8 d-none d-md-block col-md-2 col-lg-4">

<ul class="header-link">

<li class="header-item"><a href="###" class="header-item-i">首页</a></li>

<li class="header-item"><a href="###" class="header-item-i">关于</a></li>

<li class="header-item"><a href="###" class="header-item-i">商业合作</a></li>

</ul>

</div>

<div class="header-logo col-md-4">

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

</div>

</div>

</div>

</div>

<nav class="nav-contents d-md-none" id="nav">

<ul class="container">

<li><a href="###" class="nav-content">首页</a></li>

<li><a href="###" class="nav-content">关于</a></li>

<li><a href="###" class="nav-content">商业合作</a></li>

</ul>

</nav>

<script>

var nav = document.getElementById('nav');

var navName = 'nav-content-extended';

document.getElementById('truggle').onclick = function(){

if(nav.classList.contains(navName)){

nav.classList.remove(navName);

}else{

nav.classList.add(navName);

}

}

</script>

</body>

</html>

突出显示

写回答

1回答

好帮手慕久久

2020-10-25

同学你好,代码中有如下问题:

  1. 导航整体是居中显示的:

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

    原因是grid.css中,设置了container的样式。而任务要求,导航要全屏显示。

    建议设置额外样式,覆盖grid.css中的样式,实现全屏显示,如下:

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

  2. logo图,没有占满剩余空间中,如下:

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

    建议让logo占满剩余空间:

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

  3. 按钮不是四分之一圆,样式不好看,可做如下调整:

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

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

另外,下图中的选择器书写错误,导致样式不生效:

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

祝学习愉快!

1

0 学习 · 6815 问题

查看课程