


When using div css for web page layout, if the external div has a background color or border without setting its height, it will display normally under the IE browser. However, when browsing using Firefox/opera, there is a problem that the background color and border of the outermost Div do not work.
General structure
<style>.a1 {width:100px;background:red;}.b1 {background:blue;width:50px;height:600px;}</style></head><body><div class="a1"> <div class="b1"></div></div> </body>
Cause analysis: Because in Firefox and Opera: if the DIV inside is float (float) and the parent body will not calculate the child The height after the body float. This kind of calculation is supported in IE, so it works normally under IE.
So there are two prerequisites for this problem: 1. The outer div has no height set; 2. The inner div is floating (with the float attribute).
Generally, we are not sure of the height of the outer div, so we clear the float.
Realize how the background color or image inside the div will grow accordingly after it grows.
.a1{width:100px;background:red;height:auto !important; height:550px; min-height:550px;}.a1:after { content:"."; height:0; visibility:hidden; display:block; clear:both; }
1. Add code at the end of Div:
Or use
2. Use the after pseudo-class
This method is to use the after pseudo-class and content on the parent container Statement adds new content to the end of the specified current content. A common approach is to add a "dot" because it is smaller and less noticeable. Then we use it to clear the float (close the floated element) and hide the content.
This method has general compatibility, but after various hacks, it can cope with different browsers, and at the same time it can ensure that the html is relatively clean, so it is still used more often.
The code is as follows:
#a1:after{
content: ".";
height:0 ;
visibility:hidden;
display:block;
clear:both;
}
3. Set overflow to hidden or auto
This method is to set the overflow of the parent container to hidden or autot to close the floating element in a standard compatible browser.
However, when using overflow, it may affect the page performance, and This impact is uncertain, you'd better test your page on multiple browsers
4. Float external elements, float-in-float
This approach is Let the parent container also float, which takes advantage of a characteristic of floating elements? Floating elements will close floating elements. This method has good results in IE/Win and standard-compatible browsers, but the shortcomings are also obvious. The parent container may not float just because it wants to float. After all, floating is a special behavior, and sometimes the layout is not correct. Allowing it to float is also normal.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc

The core purpose of HTML is to enable the browser to understand and display web content. 1. HTML defines the web page structure and content through tags, such as, to, etc. 2. HTML5 enhances multimedia support and introduces and tags. 3.HTML provides form elements to support user interaction. 4. Optimizing HTML code can improve web page performance, such as reducing HTTP requests and compressing HTML.

HTMLtagsareessentialforwebdevelopmentastheystructureandenhancewebpages.1)Theydefinelayout,semantics,andinteractivity.2)SemantictagsimproveaccessibilityandSEO.3)Properuseoftagscanoptimizeperformanceandensurecross-browsercompatibility.


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

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

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

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor
