想问一下老师为什么我的导航条和logo没办法加上颜色呢?
来源:4-3 小慕医生项目开发(3)
流浪奇士
2021-03-08 23:44:33
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>小慕医生</title>
<meta name="Keywords" content="儿科,内科,外科,">
<meta name="Description" content="责任、品质、关爱是小慕医生的宗旨">
<link rel="stylesheet" href="css/css.css">
</head>
<body>
<!-- 页面头部 -->
<header>
<div class="header-top">
<!-- 网页logo -->
<div class="logo">
<h1>小慕医生</h1>
</div>
<!-- 网页功能区 -->
<div class="tool">
<div class="r1">
<img class="tel" src="images/tel.png" alt="">
<span class="telnumber">088-88888888</span>
<a href=""><img class="icon chinese" src="images/chinese_icon.png" alt=""></a>
<a href=""><img class="icon english" src="images/english_icon.png" alt=""></a>
</div>
<div class="r2">
<input type="text" placeholder="找医生/科室">
<!-- 图片可以放在按钮上 -->
<button><img src="images/search.png" alt=""></button>
</div>
</div>
</div>
<!-- 网页导航条 -->
<nav class="main-nav">
<ul>
<li class="cur"><a href="">首页</a></li>
<li><a href="">医院概况</a></li>
<li><a href="">医院动态</a></li>
<li><a href="">专家学科</a></li>
<li><a href="">服务指南</a></li>
<li><a href="">医院文化</a></li>
<li><a href="">信息公开</a></li>
<li><a href="">互动交流</a></li>
</ul>
</nav>
</header>
</body>
CSS:
*{
margin: 0;
padding: 0;
}
/* 去掉所有ul和ol的小圆点 */
ul ol{
list-style: none;
}
/* 超级链接去掉下划线 */
a{
text-decoration: none;
}
/* 使用继承性给body标签设置字体 */
body
{
font:normal 14px/25px '微软雅黑';
}
/* 头部的样式 */
header{
}
header .header-top{
width: 1199px;
margin: 0 auto;
/* 清除浮动 */
overflow:hidden;
}
header .header-top .logo{
margin-top: 39px;
height: 63px;
width: 192px;
float: left;
color:#00978E 100%;
font-size: 20px;
}
header .header-top .logo h1{
height: 63px;
width: 192px;
}
header .header-top .tool{
height: 67px;
width: 266px;
float: right;
margin-top: 24px;
}
header .header-top .tool .r1{
margin-bottom: 5px;
}
header .header-top .tool .r1 .tel{
width: 32px;
height: 25px;
}
header .header-top .tool .r1 .telnumber{
font-size: 20px;
color: #00978E;
display: inline-block;
width: 158px;
height: 26px;
text-align:center;
}
header .header-top .tool .r1 .icon{
width: 24px;
height: 24px;
}
header .header-top .tool .r1 .chinese{
margin-right: 5px;
}
header .header-top .tool .r2{
width: 264px;
height: 28px;
border: 1px solid rgba(202,202,202,0.60);
}
header .header-top .tool .r2 input{
width: 220px;
height: 28px;
float: left;
/* 去掉边框线 */
border: none;
padding-left: 20px;
/* 去掉鼠标点击时候的框 */
outline: none;
}
header .header-top .tool .r2 button{
float: left;
width: 20px;
height: 20px;
/* 去掉背景 */
background: none;
/* 去掉边框 */
border: none;
/* 去掉鼠标点击时候的框 */
outline: none;
/* 设置触碰时候鼠标指针的样式 */
cursor: pointer;
/* 相对定位来微调位置 */
position: relative;
top: 4px;
right: 4px;
}
header .main-nav{
height: 60px;
margin-top: 20px;
background-color: #00978E 100%;
}
header .main-nav ul{
width: 1200px;
height: 60px;
margin: 0 auto;
}
header .main-nav ul li{
float: left;
width: 150px;
list-style: none;
text-align: center;
line-height: 60px;
}
header .main-nav ul li .cur{
background-color: #015E58 100%;
}
header .main-nav ul li a{
/* 转为块级元素 */
display: block;
width: 150px;
height: 60px;
font: size 16px;
color: cornsilk;
}
header .main-nav ul li a:hover{
background-color: rgb(21, 204, 236);
}
1回答
好帮手慕言
2021-03-09
同学你好,解答如下:
1、background-color属性是设置背景颜色的,属性值是一个颜色值,而同学在颜色值后面又添加一个100%,语法是错误的,所以导致样式不生效,建议:去掉100%,代码参考:
2、logo部分的问题和上述第一点是一样的,color的属性值后面也添加了100%,样式不生效,建议:去掉100%,修改如下:

祝学习愉快~
相似问题