CSS padding compatibility usage in Ie6,ie8,firefox

Source: Internet
Author: User
Tags browsers code content different firefox it is set test

CSS padding Chinese meaning is the spacing, which refers to Div,p,span and other window content margin, it is divided into padding-top padding-right padding-bottom padding-left all sides, But padding in different browsers, this article is to tell you to solve these incompatibilities.
-
The CSS padding property defines the inner margin of an element. The Padding property accepts length or percent values, but negative values are not allowed.

For example, if you want all H1 elements to have 10-pixel internal margins on each side, this is all you need:

h1 {padding:10px} You can also set the inner margin of each edge in the order of the top, right, bottom, and left, with different unit or percentage values for each edge:

The code is as follows
H1 {padding:10px 0.25em 2ex 20%;}


Suppose you now set a padding value that is different in FF, IE8, and IE6
The first consideration is the value under FF

The code is as follows
. test{padding:10px}

Then consider the value under IE8.

The code is as follows
. test{padding:10px;*padding:9px}

Finally consider the value under IE6

The code is as follows
. test{padding:10px;*padding:9px;_padding:8px}

That's it.
Do compatibility, first consider FF, opera these browsers, and finally consider IE6.
Take the example, IE8, IE6 can be recognized *, but FF is not recognized.
So take * to do IE8 hack, and _ in FF and IE8 are not recognized, only IE6 can recognize, so with _ do IE6 hack

We talked about padding.

Single-Sided interior margin properties
You can also set up, right, down, and Zonne margins by using the following four separate properties:

The code is as follows
Padding-top
Padding-right
Padding-bottom
Padding-left

As you may have thought, the following rule implementation effect is exactly the same as the preceding shorthand rule:

The code is as follows
H1 {
padding-top:10px;
Padding-right:0.25em;
Padding-bottom:2ex;
padding-left:20%;
}


Browser support
All browsers support the Padding property.

Note: The property value "Inherit" is not supported for any version of Internet Explorer (including IE8).

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.