Let’s look at an example first Copy code The code is as follows:<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″ /> <title>Untitled Document</title> <style> #m{height:300px;width:300px;background:#ccc} #a{float:left;height:100px;width:100px;background:#f00;} #b{float:left;height:100px;*height:110px;_height:120px;width:100px;background:#0f0;} #c{clear:both;height:100px;width:100px;*width:100px;_width:120px;background:#00f;} </style> </head> <body> <div id=”m”> <div id="a"></div> <div id="b"></div> <div id="c"></div> </div> </body> </html> Here, I define three heights respectively. The first normal definition will take effect in all browsers; The second definition adds an asterisk in front, which will be recognized as the height attribute in IE6 and IE7, but Firefox and IE8 will think it is a syntax error and ignore it. According to the order of execution, the height with an asterisk is executed in IE6 and IE7, and the first normal height is invalid (or overwritten); The third height has an underscore in front. Only IE6 considers the underscore as a valid height attribute, while IE7, IE8 and Firefox regard the "_height" attribute as a non-existent attribute and therefore do not execute it, while IE6 executes it. In this way, the first two heights are covered by the underlined height in IE6. Well, through this example, you should understand that if we want to set different heights of an element in different browsers, we can use the * and _ symbols to assist in the definition. At the same time, we also learned that Microsoft is a company with a high tolerance for mistakes! Haha. However, if the first two lines of document type and namespace declarations in this example are removed, the underlined height will also be displayed normally. The width settings are the same. In our actual work, we will often encounter different browser interpretations of margin attributes, then asterisks and underscores can be of great help. |
<<: A brief discussion on how Tomcat breaks the parent delegation mechanism
>>: Several ways to vertically and horizontally center in CSS3 with indefinite height and width
There has been a lot of discussion about H1 recent...
B-tree is a common data structure. Along with him...
This effect is most common on our browser page. L...
Table of contents JSON appears Json structure Jso...
1. Go to the location where you want to store the...
After I finished reading JavaScript DOM, I had a ...
Table of contents 1. Install dependencies 2. Conf...
Causes and consequences 1. When using the ansible...
Effect Need environment vue elementUI Drag and dr...
In fact many people will say “I’ve seen that table...
Detailed explanation of mysql count The count fun...
Preface This article mainly introduces the releva...
I encountered a small problem today and struggled ...
1. Set CORS response header to achieve cross-doma...
Congratulations on finally convincing your bosses...