CSS Compatibility tips Daquan (iii)

Source: Internet
Author: User
Tags add object definition class definition

Web page Production WEBJX article introduction: 9. Height is not suitable for height is not suitable for when the height of the inner object changes when the outer height can not be automatically adjusted, especially when the inner layer object using margin or paddign. Example: #box {background-color: #eee;} #box content resolution techniques in P {margin-top:20px;margin-bottom:20px; Text-align:center} P objects: in P

9. Height not suitable

Height is not adaptable when the height of the inner object changes when the outer height is not automatically adjusted, especially when the inner object uses margin or paddign.

Cases:

#box {background-color: #eee;}

#box p {margin-top:20px;margin-bottom:20px; text-align:center;}

  

  

Content in the P object

  

Workaround: Add 2 empty div objects to the P object CSS code:. 1{height:0px;overflow:hidden;} Or add the border attribute to the Div.

10. IE6 Why there is a gap under the picture

There are a number of techniques to solve this bug, either by changing the layout of the HTML, or by setting IMG to Display:block or setting the Vertical-align attribute to Vertical-align:top

Bottom middle text-bottom can be solved.

11. How to align text with an input box

Plus vertical-align:middle;

  

What is the difference between defining ID and class in the 12.web standard?

A. Web standards are not allowed to duplicate IDs, such as Div id= "AA" does not allow repeat 2 times, and class definition is a class, theoretically can be infinitely repetitive, so need to refer to the definition of multiple references can use him.

Two. Priority issues for attributes

ID priority is higher than class, look at the example above

Three. Convenient JS and other client-side script, if you want to script an object on the page, you can define an ID, otherwise only the use of traversal page elements plus the specified specific attributes to find it, this is a relatively waste of time resources, far less than a simple ID.

Source: Web Front Wind

Responsible Editor: Bluehearts



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.