Home Web Front-end HTML Tutorial Common errors of div css, compatibility methods, etc._html/css_WEB-ITnose

Common errors of div css, compatibility methods, etc._html/css_WEB-ITnose

Jun 24, 2016 pm 12:29 PM

Common mistakes

1. Check whether the HTML element has spelling errors and whether the closing tag is forgotten

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 any 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, then you can determine where the error occurred. Location.

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

Using the float attribute for layout may 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 layout of the surrounding float elements will be confused. 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

IE has a bug when displaying float elements with margin and padding specified. 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 display properly. 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 of different browsers are still different no matter how you adjust it, then you can check whether you forgot to write the following line of DTD at the beginning of the page:

  Commonly used tools

 1. Notepad.exe notepad, (small program, easy to edit manually at any time, Less junk code, no visual preview)

2.Dreamweaver (old web page editing tool, full-featured, relatively large program)

3..editplus (should be an upgraded version of the notepad tool, Code editing has color tips)

4. Notepad (a very unique editor, open source software, supports multiple development languages)

5. Ultraedit (a set of powerful text editors) Editor)

6. Golive (a product that will replace Dreamweaver in the future)

7. Topstyle (it has quite a few functions, and comes with a CSS code checking function to reduce the chance of writing errors. Especially its The detailed introduction of CSS instructions in the HELP file is very suitable for use as a reference document and for learning by people who are new to CSS)

Compatibility method

Difference between IE6 and FF: background:orange;*background:blue;

Difference between IE6 and IE7: background:green !important;background:blue;

Difference between IE7 and FF: background:orange; *background:green;

Difference between FF and IE7 , IE6: background:orange;*background:green !important;*background:blue;

IE7, IE8 compatible:

 HEAD

 1. Several browsers in CSS support different keywords, which can be repeatedly defined for browser compatibility! important can be recognized by FireFox and IE7* Yes Recognized by IE6 and IE7_ Recognized by IE6* Recognized by IE7

 2. IE-specific conditional comments

 3. Several browsers have different opinions on the actual Explanation of pixels IE/Opera: Actual width of object = (margin-left) width (margin-right) Firefox/Mozilla: Actual width of object = (margin-left) (border-left-width) (padding- left) width (padding-right) (border-right-width) (margin-right)

4. Mouse gesture problem: FireFox’s cursor attribute does not support hand, but it supports pointer, and IE supports both; so for compatibility, pointer is used

5. When setting the Style attribute of the HTML tag in FireFox , all position, width, height and size values ​​must be followed by px. IE also supports this writing method, so the px unit is added uniformly. For example, Obj.Style.Height = imgObj.Style.Height 'px';

6. FireFox cannot parse the abbreviated padding attribute setting, such as padding 5px 4px 3px 1px; it must be changed to padding-top:5px; padding -right:4px; padding-bottom:3px; padding-left:1px0;

7. When eliminating the indentation of lists such as ul and ol, the style should be written as: list-style:none;margin:0px; padding:0px; The margin attribute is valid for IE, and the padding attribute is valid for FireFox

8. CSS control transparency: IE: filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=60); FireFox :opacity:0.6;

9. CSS control rounded corners: IE: does not support rounded corners; FireFox: -moz-border-radius:4px; or -moz-border-radius-topleft:4px; -moz -border-radius-topright:4px; -moz-border-radius-bottomleft:4px; -moz-border-radius- bottomright:4px;

 10. CSS double-line bump border: IE: border:2px outset; FireFox: -moz-border-top-colors: #d4d0c8 white; -moz-border-left-colors: #d4d0c8 white; -moz-border-right-colors:#404040 #808080; -moz-border-bottom -colors:#404040 #808080;

 11. IE supports the CSS method cursor:url() to customize the cursor style file and scroll bar color style; FireFox does not support the above two

12. IE has a bug where the Select control is always on top, and all CSS does not work on the Select control

13. IE supports Label tags in Form, including pictures and text content; FireFox does not support including pictures Label, clicking the picture will not cause the Radio or CheckBox labeled label for to have an effect

 14. TextArea in FireFox does not support the onScroll event

 15. FireFox does not support inline and block of display

16. When FireFox sets margin-left and margin-right to auto on Div, it is already centered, but it does not work in IE

17. When FireFox sets text-align on Body, Div needs to set margin: auto( Mainly margin-left margin-right) can be centered

18. It is best to set the CSS style of hyperlinks in this order: L-V-H-A. That is, This can be avoided Some hyperlinks that have been visited no longer have hover and active styles

19. To set automatic line wrapping for long paragraphs in IE, set word-wrap:break-word in CSS; use JS insertion method in FireFox to achieve this , the specific code is as follows:

 20. In the sub After adding the floating attribute to the container, the container will not be able to open automatically. Solution: Add a CSS clear: both;

to the next label after the label ends. 21. IE6 explains the margins after floating Solution to double the actual margin: add display:inline

22. There will be a gap below the image under IE6 Solution: add display:block to img or set the vertical-align attribute to vertical-align :top | bottom |middle |text-bottom

 23. There is a gap between the two layers under IE6. Solution: Set the right div to also float float:left or define margin-right:-3px relative to IE6;

24. How to display ellipsis when the content in LI exceeds the length (only applicable to IE)

 25. Set the height and line height of the element to The same value will center the text vertically

 26. To align the text and text input box, you must add vertical-align:middle; attribute setting in CSS

 29. IE6 cannot define a container with a height of about 1px due to the default line height problem. Solution: adjust the height in CSS Container settings such as: overflow:hidden | zoom:0.08 | line-height:1px

 30. Setting the transparent attribute to Flash can make the layer appear on top of Flash

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1253
24
HTML: The Structure, CSS: The Style, JavaScript: The Behavior HTML: The Structure, CSS: The Style, JavaScript: The Behavior Apr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML, CSS, and JavaScript: Web Development Trends The Future of HTML, CSS, and JavaScript: Web Development Trends Apr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The Future of HTML: Evolution and Trends in Web Design The Future of HTML: Evolution and Trends in Web Design Apr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative Overview HTML vs. CSS vs. JavaScript: A Comparative Overview Apr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Building the Structure of Web Pages HTML: Building the Structure of Web Pages Apr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML vs. CSS and JavaScript: Comparing Web Technologies HTML vs. CSS and JavaScript: Comparing Web Technologies Apr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

HTML: Is It a Programming Language or Something Else? HTML: Is It a Programming Language or Something Else? Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

From Text to Websites: The Power of HTML From Text to Websites: The Power of HTML Apr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

See all articles