Multiple settings in the navigation bar and multiple settings in the navigation bar
Note: For simple people, do not speak quietly .... I am a record.
By default, the webpage has the margin value and padding value, and the subsequent elements do not take effect in the modification process of margin and padding, therefore, in the style setting process, the margin and padding values of all elements are first cleared to 0;
Code: * {padding: 0px; margin: 0px;} // * indicates all
You can set the desired margin and padding values on the subsequent elements to take effect;
For example: (for this reason, the idea is logical, but it is not what you want)
I did this based on the navigation of the imooc website (full hands-on, because I am a newbie and want to give it a try)
Below is the Code Section
<Div class = "nav"> <ul> <li> <a href = "#"> comment </a> </li> <a href = "# "> Q & a </a> </li> <a href =" # "> Notes </a> </li> <a href = "# "> classmate Code </a> </li> </ul> </div>
Css style
* {Margin: 0px; padding: 0px ;}. nav {border-bottom: 1px solid # c0c0c0; width: 1000px; height: 60px; margin-left: 40px; // background-color: # c3ffdd ;} ul li {list-style-type: none; width: 120px; float: left;} li a {display: block; text-decoration: none; color: black; font-family: ""; text-align: center; line-height: 60px;} li a: hover, li a: active {color: # f00 ;} li a: focus {border-bottom: 2px solid # f00 ;}
Previously, the content of my life and death label hover was not on the far left of the bottom border. After the code was set, it was enough.