CSS tips

高洛峰
Release: 2017-02-27 09:40:18
Original
1458 people have browsed it

We still need to remember some classic CSS techniques, which can save us a lot of time. Below, I will recommend a few better CSS techniques for you:

1. Use the same navigation code on different pages

Many web pages have navigation menus. When entering a certain page, the corresponding item on the menu should turn gray, while other pages should light up. . Generally, to achieve this effect, you need to write a program or design specifically for each page. Now you can achieve this effect with CSS.

First, use the CSS class in the navigation code:


<ul> 
<li><a href="#" class="home">首页</a></li> 
<li><a href="#" class="about">关于我们</a></li> 
<li><a href="#" class="contact">联系我们</a></li> 
</ul>
Copy after login


Then specify the Body for each page separately An id with the same name as the above class. Such as .

Then design the CSS as follows:


#home .home, #about .about, #contact .contact 
{ 
commands for highlighted navigation go here 
}
Copy after login


##Here, when the id is set to home, .home will start The effect is that the row of navigation bars whose class is set to home will display special effects. The same goes for other pages.

How about it? Isn’t it very simple?

2. Comparison of Block and inline elements

All HTML elements belong to one of block and inline. The characteristics of the block element are:

always starts on a new line;

Height, line height and top and bottom margins can all be controlled;

The default width is 100% of its container unless a width is set

,

,

,
,

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template