This article mainly introduces relevant information on the detailed explanation of the position:fixed problem and the effect of scrolling with the scroll bar in IE6. I hope this article can help everyone. Friends in need can refer to it
Detailed explanation of the position: fixed problem in IE6 and the effect of scrolling with the scroll bar
Foreword:
In "[jQuery] IE6 compatible scrolling monitoring" (Click to open the link) It is mentioned that to solve the IE6 fixed problem, specifically, you need to introduce a js file and declare a script to declare the fixed positioning for this p to solve it. This is not good at first. In addition to the difficulty of managing the imported Javascript, you also have to introduce JavaScript in the head statement, and then declare an id for the p, and then make a statement in the script. It is really annoying.
Using position: fixed is nothing more than trying to achieve the following effect.
Basically position: fixed is no problem in all browsers above IE7:
IE8:
Yehu Zen FireFox :
However, since there is no position: fixed attribute directly in IE6, the following effect must be made:
It can only be solved by using position: absolute; and adding a javascript script executed in the css style.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> <style type="text/css"> .fixedbox { background: #69C; height: 60px; width: 100px; position: fixed; bottom: 100px; /*IE6实现position: fixed;*/ /*等价于position: fixed;虽然代码好长,但是根本就不用管*/ _position: absolute; _top: expression(eval( document.documentElement.scrollTop + document.documentElement.clientHeight-this.offsetHeight- (parseInt(this.currentStyle.marginTop,10)||0)- (parseInt(this.currentStyle.marginBottom,10)||0))); /*等价于position: fixed;虽然代码好长,但是根本就不用管*/ _margin-bottom:100px;/*设置位置,不要用bottom,而是改用margin-bottom,margin-xx来实现*/ } </style> </head> <body> <p style="float:left;width:80%;min-height:100px;"> <p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p> <p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p> <p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p> <p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p><p>sss</p> </p> <p style="float:left;width:20%;min-height:100px;"><p class="fixedbox"></p></p> <p style="clear:both"></p> </body> </html>
The above code, for IE6 styles, is preceded by _, and the _ part is the IE6-specific rewritten style statement. For details, see "[CSS] About !important, *, and _Symbol》(Click to open the link)
In fact, in IE6, the following CSS:
.fixed{ position: absolute; top: expression(eval( document.documentElement.scrollTop + document.documentElement.clientHeight-this.offsetHeight- (parseInt(this.currentStyle.marginTop,10)||0)- (parseInt(this.currentStyle.marginBottom,10)||0))); }
is equivalent to that of other browsers:
.fixed{ position: fixed; }
Of course IE6 The CSS that implements position: fixed may not work properly in some browsers, so add an underscore _ in front of each style to indicate that it will only be executed in IE6.
At the same time, after IE6 should have the above style, do not use right, top, left, bottom to position like other browsers, but use margin-bottom, margin-left, margin-right to set the position: fixed The position of p,
You also need to pay attention when adjusting the position of p here. Since the above-mentioned CSS compatible with IE6 uses the top attribute, setting margin-top will not work. If you want to set this p When floating, how far away from the top of the browser is, you should write like this:
.fixed{ /*IE6实现position: fixed;*/ _position: absolute; _top: expression(eval(document.documentElement.scrollTop)); _margin-top:100px; }
The reason why the code about _top here is so much shorter is because there is no need to use document.documentElement.clientHeight to get it Browser display window size.
And -this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0) is all for fine-tuning to be more precise, You don’t have to add it if you don’t want it, it’s just a little visual effect.
Furthermore, as you can see from the above code, I did not set the right and left of the fixedbox because I want it to remain stable when scrolling with the scroll bar. The float:left attribute of parent p.
That is, the blue color block on the right and a lot of sss on the left are still divided into 80% and 20%.
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
JavaScript memory leak problem in versions before IE9 (detailed summary)
JavaScript hasOwnProperty() function (picture Text tutorial, with code examples)
The above is the detailed content of Detailed explanation of position:fixed problem in IE6. For more information, please follow other related articles on the PHP Chinese website!

HTMLtagsareessentialforstructuringwebpages,enhancingaccessibility,SEO,andperformance.1)Theyareenclosedinanglebracketsandusedinpairstocreateahierarchicalstructure.2)SemantictagslikeandimproveuserexperienceandSEO.3)Creativetagslikeenabledynamicgraphics

Self-closingtagsinHTMLandXMLaretagsthatclosethemselveswithoutneedingaseparateclosingtag,simplifyingmarkupstructureandenhancingcodingefficiency.1)TheyareessentialinXMLforelementswithoutcontent,ensuringwell-formeddocuments.2)InHTML5,usageisflexiblebutr

To build a website with powerful functions and good user experience, HTML alone is not enough. The following technology is also required: JavaScript gives web page dynamic and interactiveness, and real-time changes are achieved by operating DOM. CSS is responsible for the style and layout of the web page to improve aesthetics and user experience. Modern frameworks and libraries such as React, Vue.js and Angular improve development efficiency and code organization structure.

Boolean attributes are special attributes in HTML that are activated without a value. 1. The Boolean attribute controls the behavior of the element by whether it exists or not, such as disabled disable the input box. 2.Their working principle is to change element behavior according to the existence of attributes when the browser parses. 3. The basic usage is to directly add attributes, and the advanced usage can be dynamically controlled through JavaScript. 4. Common mistakes are mistakenly thinking that values need to be set, and the correct writing method should be concise. 5. The best practice is to keep the code concise and use Boolean properties reasonably to optimize web page performance and user experience.

HTML code can be cleaner with online validators, integrated tools and automated processes. 1) Use W3CMarkupValidationService to verify HTML code online. 2) Install and configure HTMLHint extension in VisualStudioCode for real-time verification. 3) Use HTMLTidy to automatically verify and clean HTML files in the construction process.

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.

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.


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

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

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version
