10 common mistakes in DIV CSS layout_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:31:20
Original
1268 people have browsed it

Top 10 Common Mistakes in DIV CSS Layout

Time: 2009-04-11 21:08 Source: Internet Author :Rank name clicks: 5 times

If you encounter any problems, please go to the ajax technical forum for help and we will try our best to answer your questions.

CSS+DIV is one of the commonly used terms in website standards (or "WEB standards"). It is usually used to explain the difference from the positioning of tables in HTML web design language, because XHTML websites In the design standards, table positioning technology is no longer used, but CSS div is used to achieve various positioning. It's easy to make some mistakes when coding DIV CSS. This article lists some common mistakes:

1. Check whether the HTML element has spelling errors or forgets the closing tag

Even veterans often make mistakes in the nesting relationship of divs. You can use Dreamweaver's verification function to check for errors.


 2. Check whether the CSS is correct

Check whether there are spelling errors, whether you forgot the ending }, etc. You can use CleanCSS to check CSS for spelling errors. CleanCSS is a tool to reduce weight for CSS, but it can also check for spelling errors.

 3. Determine where the error occurred

If the error affects the overall layout, you can delete the div blocks one by one until the display returns to normal after deleting a certain div block. You can determine where the error occurred.

 4. Use the border attribute to determine the layout characteristics of the error element

Using the float attribute layout will cause errors if you are not careful. At this time, add the border attribute to the element to determine the element boundary, and the cause of the error will be revealed.

5. The parent element of a float element cannot specify the clear attribute

If you use the clear attribute on the parent element of a float element under MacIE, the surrounding float elements will be laid out confusion. This is a famous bug of MacIE. If you don't know it, you will take detours.

6. Float elements must specify the width attribute

Many browsers have bugs when displaying float elements without specified width. So regardless of the content of the float element, the width attribute must be specified for it.

In addition, try to use em instead of px as the unit when specifying elements.

7. Float elements cannot specify attributes such as margin and padding

There is a bug when using float elements. Therefore, do not specify margin and padding attributes on float elements (you can nest a div inside the float element to set margin and padding). You can also use hacks to specify special values ​​for IE.

8. The sum of the widths of float elements must be less than 100%

If the sum of the widths of float elements is exactly 100%, some ancient browsers will not be able to Display normally. Therefore, please ensure that the sum of the widths is less than 99%.

9. Have you reset the default style?

Different browsers have different interpretations of certain attributes such as margin, padding, etc. Therefore, it is best to set all margin and padding to 0, list style to none, etc. before development.

10. Did you forget to write the DTD?

If the display results are still different no matter how you adjust different browsers, then you can Check if you forgot to write the following line of DTD at the beginning of the page:

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!