html5制作导航条

时间:2022-12-10 05:18:03

(1)background-repeat:no-repeat;图片不平铺

(2)使用<ul>和<li>便签,代码简介有序、易于编排。

(3)在引入外部css文件时,<link>标签中的rel是关联的意思,rel="stylesheet";

(4)display:inline;实现使多个<div>像<span>标签显示在一行。

(5)list-style:none;列表样式:无。  用于在一个声明中设置列表的所有属性的简写属性。涵盖了所有其他列表样式属性,仅作用于具有display值为list-item的对象(如li对象)。

(6)text-decoration:none;无值;underline定义文本下的一条线;overline定义文本上的一条线;line-through定义穿过文本下的一条线;blink定义闪烁的文本。

(7)outline:none;为不设置边框;语法:Object.style.outline = outlineWidth outlineStyle outlineColor 设置边框宽、样式、颜色。

(8)target="_self" <a>标签内设置,本页面打开;target="_blank"新打开一个页面

(9)定义伪类链接,鼠标经过更改颜色或其他a:hover{color:#abcdef;}

test.css

 body{
margin:0px;
background-image:url(images/body.jpg);
background-repeat:no-repeat;
width:1003px;
} nav{
float:left;
width:920px;
height:40px;
background-image:url(images/students.jpg);
margin:100px 0 0 0;
padding:;
} nav ul{
float:left;
margin:0px;
padding:0 0 0 0;
width:920px;
list-style:none;
}
nav ul li{
display:inline;
}
nav ul li a{
float:left;
padding:12px 40px;
text-align:center;
font-size:14px;
background:url(images/user.png) center right no-repeat;
color:#fff;
font-family:Tahoma;
outline:none;
} nav li a:hover{
color:#2a5f00;
}

html内容

 <!DOCTYPE html>
<html>
<head>
<title>MyHtml.html</title>
<link href="CSS/test.css" rel="stylesheet" type="text/css" />
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body>
<header>
<nav>
<ul>
<li><a href="#" title="首页" target="_self">首页</a></li>
<li><a href="#" title="首页" target="_self">男男女女</a></li>
<li><a href="#" title="首页" target="_self">急急急</a></li>
<li><a href="#" title="首页" target="_blank">呸呸呸</a></li>
</ul>
</nav>
</header>
</body>
</html>