老师看一下有没有需要改进的

来源:4-4 自由编程

前端小白白白白白白

2020-09-11 15:16:45

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
<link rel="stylesheet" href="css/grid.css">
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="css/muke.css">
</head>
<body>
<header class="header-container">
<div class="container">
<div class="header-logo-container col-12">
<img src="img/logo.png">
</div>
<div class="header-nav-container d-none d-md-block">
<!-- 在中屏以上显示 -->
<ul class="nav">
<li class="nav-item">
<a href="#">首页</a>
</li>
<li class="nav-item">
<a href="#">关于</a>
</li>
<li class="nav-item">
<a href="#">商业合作</a>
</li>
</ul>
</div>
<div class="header-btn-toggle d-block d-md-none">
<div class="btn" id="btn">
<span></span>
<span></span>
</div>
</div>
</div>
</header>
<div class="mb-nav-container d-block d-md-none" id="mb-nav">
<ul class="mb-nav">
<li class="mb-nav"><a href="#">首页</a></li>
<li class="mb-nav"><a href="#">关于</a></li>
<li class="mb-nav"><a href="#">商业合作</a></li>
</ul>
</div>
<script type="text/javascript">
document.getElementById('btn').onclick=function(){
if(document.getElementById('mb-nav').classList.contains('active')){
document.getElementById('mb-nav').classList.remove('active')
}else{
document.getElementById('mb-nav').classList.add('active')
}
}
</script>
</body>
</html>

muke.css

/* 布局start */
* {
	padding: 0;
	margin: 0;
	box-sizing: border-box;
}

header {
	height: 100px;
	position: relative;
	border-bottom: 1px solid #dadada;
	overflow: hidden;
}

header.header-container {}

header.header-container .header-logo-container {
	display: flex;
	justify-content: center;
	align-items: center;
}

.header-nav-container {
	position: absolute;
	left: 0;
}

.header-container .container,
.header-nav-container,
.header-logo-container {
	height: 100%;
}

.header-logo-container img {
	width:250px;
}

.nav {
	display: flex;
	list-style: none;
}

.nav a {
	line-height: 100px;
	text-decoration: none;
	font-size: 20px;
	font-weight: 600;
	color: #666666;
	margin-left: 30px;
}

.header-btn-toggle {
	position: absolute;
	/* display: flex!important; */
	height: 100%;
	align-items: center;
	left: 20px;
	top: 60px;
}

.header-btn-toggle .btn {
	width: 30px;
	position: relative;
	z-index: 2;
	cursor: pointer;
}

.header-btn-toggle .btn span {
	display: block;
	width: 100%;
	height: 5px;
	background-color: white;
}
.header-btn-toggle .btn span:nth-child(2){
	margin-top: 10px;
}
@media (max-width: 767px) {
	header::after {
		content: "";
		display: block;
		width: 300px;
		height: 300px;
		background-color: rgba(255, 0, 0, .8);
		position: absolute;
		left: -200px;
		top: 0px;
		border-radius: 50%;
		z-index: 1;
	}
}

.mb-nav-container {
	background-color: #DDDDDD;
	height: 0;
	position: relative;
	overflow: hidden;
	top: -1px;
	transition: height .5s;
}

.mb-nav-container.active {
	height: 121px;
	border-bottom: 1px solid #000000;
}

.mb-nav a {
	text-decoration: none;
	color: white;
	line-height: 40px;
}

/* 布局end */


写回答

1回答

好帮手慕星星

2020-09-11

同学你好,代码实现效果很棒,不需要修改了。继续加油,祝学习愉快!

0

0 学习 · 6815 问题

查看课程