


div css browser compatibility and understanding of css hack_html/css_WEB-ITnose
After writing div css code for so long, I really don’t know what this hack is? I checked online carefully. Simply put, the process of writing different CSS codes for different browsers is called CSS hack, also called writing CSS hack.
Principle of CSS hack: Because different browsers have different support and parsing results for CSS, and also due to the priority relationship in CSS. We can use this to write different CSS for different browsers.
For example, IE6 can recognize underline "_" and asterisk "*", IE7 can recognize asterisk "*", but cannot recognize underline "_", and firefox cannot recognize both. Wait
The writing order is generally to write the CSS of browsers with strong recognition capabilities at the end
Browser priority level: FF
Let’s take a look at the following examples of div css browser compatibility:
#demo {width:100px;} /* Executed by FIREFOX, IE6, IE7.*/
* html #demo {width:120px;} /* will be executed by IE6, and the previous definition will be overwritten by the later one, so the width of #demo will be 120px in IE6; */
* html # demo {width:130px;} /* will be executed by IE7*/
So in the end, the width of #demo is interpreted by the three browsers as:
firefox:100px;
ie6:120px;
ie7:130px;
The above example can also be solved using the method in my previous article "div css browser compatibility!" No more examples. ”
div css browser compatibility tips:
① Vertically centered. Set line-height to the same height as the current div, and then pass vertical-align: middle.( Be careful not to wrap the content.)
② Center horizontally. margin: 0 auto; (Of course it is not a panacea)
③ If you need to add styles to the content in the a tag, you need to set display: block; (common in Navigation tag)
④ The difference in understanding of BOX between FF and IE leads to a 2px difference. There are also problems such as the margin of a div set to float being doubled under IE.
⑤ The ul tag under FF has list-style and padding by default. . It is best to declare it in advance to avoid unnecessary trouble. (Common in navigation tags and content lists)
⑥ Do not set the height of the div as an external wrapper. It is best to add overflow: hidden. to achieve the goal. Height adaptive.
⑦ Regarding the hand cursor. cursor: pointer. And hand is only applicable to IE.
⑧ Setting padding on div under FF will cause the width and height to increase, but IE does not Yes. (can be solved with !important)
Note: Most of the css styles for firefox IE6 and IE7
are now hacked with !important. For IE6 and firefox tests, it can be displayed normally,
but IE7 !important can be interpreted correctly, but it will cause the page not to be displayed as required! Find a pin
A good hack for IE7 is to use "*html". Now browse it with IE7 and there should be no problem.
Now write a browser compatible one:
#cshk{ height:20px; } /* Moz */
* html #cshk {height:50px; } /* IE6 */
* html #cshk {height:80px; } /* IE7 */
Then the height under firefox is 20, the height under IE6 is 50, and the height under IE7 is 80.
Let me give you some advice: Is it better to use CSS Hack or not? In fact, when designing a website, it would be best if you can consider some possible places where CSS bugs may occur. I try to avoid CSS bugs when designing a website. Most experts don’t use hacks.

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

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 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 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.

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.

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

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 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.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Notepad++7.3.1
Easy-to-use and free code editor