Home > Web Front-end > CSS Tutorial > Several commonly used classic CSS techniques_Experience exchange

Several commonly used classic CSS techniques_Experience exchange

WBOY
Release: 2016-05-16 12:05:00
Original
1189 people have browsed it

Use line-height for vertical centering

line-height:24px;
When using a fixed-width container and need a row to be vertically centered, use line-height (the height is the same as the parent layer container) , more vertical centering summary can be seen here.

Clear container floats

#main {
overflow:hidden;
}
Such a problem was also mentioned before. For more information, you can see here.

Do not allow links to wrap

a {
white-space:nowrap;
}
The above settings can prevent links from wrapping, but I personally recommend long The link will have the corresponding line (for a discussion of line breaks, see the record in the center of the circle).

Always let Firefox display scroll bars

html {
overflow:-moz-scrollbars-vertical;
}
For more Mozilla/Firefox private CSS properties, please refer to here. For cross-browser support, you can also use

body, html {
min-height:101%;
}
Center the block element horizontally

margin: 0 auto;
In fact, it is

margin-left: auto;
margin-right: auto;
Basically all CSS textbooks will explain this technique, don’t forget to add it width. You can also use

body{
text-align: center;
}
and then define the inner container

text-align: left;
Restore .

Hide the scroll bar of the Explorer textarea

textarea {
overflow:auto;
}
Exploer textarea has vertical scroll bars by default (don’t ask me why) .

Set printing paging

h2 {
page-break-before:always;
}
page-break-before attribute can set paging when printing web pages.

Remove the dotted box on the link

a:active, a:focus {
outline:none;
}
Firefox will focus on the link by default (or click ), add a dotted frame, which can be deleted using the properties above.

The simplest CSS reset

* {
margin: 0; padding: 0
}
If you want to be "complex", refer to YUI's approach (and here). Some users also expressed their opinions in the original message

I have to agree with Niall Doherty, * {margin: 0px; padding: 0px;}
basically means "traverse every css element and give it these attributes". That is a very unnecessary strain on the server and
a bad semantic practice, as you have to give some elements
padding/margin again, after stripping them.

Related labels:
source:php.cn
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