关于html代码问题~

来源:百度知道 编辑:UC知道 时间:2024/05/07 15:55:10
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#nav{ width:9em;

margin:0 auto;
padding:8px;
font-size:14px;
border:solid 1px #cccccc;
}
#nav ul{list-style:none;}
#nav a:hover{background-color:#333333;
color:#FFFFFF;
text-decoration:none;
display:block;
margin:auto;
text-align:center;
align}
</style>

css修改如下:

<style type="text/css">

#nav{ width:9em;

margin:0 auto
padding:8px;;
font-size:14px;
border:solid 1px #cccccc;
}
#nav ul{list-style:none;margin:0px;}
#nav ul li {margin:0px;text-align:center;}

#nav a:hover{background-color:#333333;
color:#FFFFFF;
text-decoration:none;
display:block;
margin:auto;
text-align:center;
align}
</style>

问题出在ul,li的样式margin默认参数不为0.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>