Css General notes 01 -- navigation background

Source: Internet
Author: User

Css General notes 01 -- navigation background

I have summarized some small issues that may be solved by css when I first came into contact with the front-end. I will gradually share with you the background issues of navigation, which are often seen on webpages, when you place the mouse over a navigation button, there will be some special effects, such as the background. This is the most common one. Let's solve it. This is a method that can be used in all navigation, this method can be used to remove the first and third sides.

The html code is as follows:

1 

The css code is as follows:

1 # nav {width: 300px; height: 80px; padding_top: 20px; margin: 0 auto;} 2 # nav li {float: left; heigth60px; margin-left: 10px ;} 3 # nav a {float: left; heigth60px; line-height: 60px; font ......} // set the height of li text. The result is centered. 4 # nav strong {float: left; height: 60px;} 5 # nav span {float: left; height: 60px; padding: 0 14px;} // set the width of the left and right sides of each li; 6 // place the mouse on the navigation background. effect 7 # nav a: hover {background: url (.......) repeat-x;} // The middle background is repeated. 8 # nav a: hover strong {background: url (.......) no-repeat left;} // left background, no duplicates, on the left; 9 # nav a: hover span {background: url (.......) no-repeat right;} // background on the right, which is not repeated and placed on the right;

The following must be modified:

1.html files must be imported by adding css files; 2.css files must be corrected by selecting the images to be used.

This is the running effect I wrote earlier (the sample code above is incomplete and cannot be run ):

When you place the cursor over the second navigation button, a background image of the rounded corner will appear, because the first "HOME" is set to active, so it is always in the background state:

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.