css
ul {
list-style-type: none;
margin: 0px;
padding: 0px;
width: 400px;
height: 30px;
background-color: blue;
}
a:link,a:visited{
text-decoration: none;
background-color: red;
text-align: center;
width: 50px;
color: aliceblue;
}
a{
line-height: 30px;
}
a:active,a:hover{
background-color: crimson;
}
li{
display: inline;
padding-left: 14px;
}
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="test.css">
</head>
<body>
<ul>
<li><a href="">导航栏1</a></li>
<li><a href="">导航栏2</a></li>
<li><a href="">导航栏3</a></li>
<li><a href="">导航栏4</a></li>
<li><a href="">导航栏5</a></li>
</ul>
</body>
</html>
本文介绍了一种使用CSS样式来定制导航栏的方法。通过设置ul元素的样式属性,如宽度、高度、背景颜色等,实现了统一的布局效果。同时,通过对a标签的不同状态进行样式定义,确保了导航项在鼠标悬停或点击时能呈现出良好的交互反馈。
17万+

被折叠的 条评论
为什么被折叠?



