CSS implements first-level navigation bar
Mar 22, 2018 pm 01:04 PMThis time I will bring you CSS to implement a first-level navigation bar. What are the precautions for implementing a first-level navigation bar with CSS? The following is a practical case, let’s take a look.
Step one: Introduce the css style sheet, create a new layer with the id nav, and use the <ul>, <li>, <a> tags to create the complete effect.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" type="text/css" href="css/yiji.css"/> </head> <body> <p id="nav"> <ul> <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> </p> </body> </html>
The second step is to set the CSS style:
1. Set the attributes of nav
#nav{ width: 500px; height: 50px; border: 1px solid red; }
##2. Clear the dot in front of the <ul> tag #nav ul{
list-style: none;
}
3. Set the properties of the <a> tag contained under <ul>#nav ul li a{
width: 98px;
height: 50px;
float: left;
border: 1px solid red;
text-align: center;
line-height: 50px;
text-decoration: none;
}
4 .Set the mouse over effect#nav ul li a:hover{
background-color: #ABCDEF;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="css/yiji.css"/>
</head>
<body>
<p id="nav">
<ul>
<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>
</p>
</body>
</html>
*{
margin: 0;
padding: 0;
}
#nav{
width: 500px;
height: 50px;
border: 1px solid red;
margin: 30px;
}
#nav ul{
list-style: none;
}
#nav ul li a{
width: 98px;
height: 50px;
float: left;
border: 1px solid red;
text-align: center;
line-height: 50px;
text-decoration: none;
}
#nav ul li a:hover{
background-color: #ABCDEF;
}
Recommended reading:
The difference between nth-child and nth-of-type in CSS3 and usage skillscss3 Detailed explanation of the new attribute box-sizingCSS draws a red heartThe above is the detailed content of CSS implements first-level navigation bar. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What language is the browser plug-in written in?
