Home >Web Front-end >JS Tutorial >The perfect solution for IE6 fixed_javascript skills

The perfect solution for IE6 fixed_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:08:531349browse
The first method: pure CSS
There are currently many solutions (pure CSS) on the Internet:
Copy code The code is as follows:

html{overflow:hidden;}
body{height:100%;overflow:auto;}
#rightform form{ position:absolute;right:30px;top50px;}

This method has an unresolved bug: under IE6, all position:absolute will be turned into "floating" elements; there is also the use of js The object will flicker when the scroll bar is scrolled. The following method combines CSS and js to solve the above problem.
Copy code The code is as follows:

.org/1999/xhtml">


< title>IE6 fixed



1111
















< br />







< ;br />


































































< br />







< ;br />




show





Only fixed in the vertical direction is implemented. To achieve horizontal fixed, set _left:expression(documentElement.scrollLeft "px");
Use a fixed background for to prevent the scroll bar from flickering when scrolling; if If you want to set the scrolling background and cause conflicts, you can write the code in the html selector, such as:
Copy the code The code is as follows :

html {
_background-image: url(about:blank);
_background-attachment: fixed; /* prevent screen flash in IE6 */
}
body {
background-image: url(1.jpg);
background-attachment: scroll;
}

Second method JavaScript
Copy code The code is as follows:

.org/1999/xhtml">




position_fixed test


Test content.........


Test content..... ....


Test content.........


Test content.........


Test content..........


Test content..........

Test content..........


Test content..........


Test content.........


Test content..........


Test content.........


Test content.........


Test content.. .......


Test content.........


Test content... ...


Floating content 2

My location It's fixed! Pull the scroll bar to see the effect.





ie6 perfect solution for postion:fixed
Go today A foreigner saw that his website was very smooth but had no js. He was curious, so it turns out. . It's so clever. Share it. It saves resources relatively speaking. But the effect is good, easy to use, and takes into account w3c. Haha


ie-stuff.css

Copy Code The code is as follows:
#footer {
position: absolute;
bottom: auto;
clear: both;
top :expression(eval(document.compatMode &&
document.compatMode=='CSS1Compat') ?
documentElement.scrollTop
(documentElement.clientHeight-this.clientHeight) - 1
: document.body. scrollTop
(document.body.clientHeight-this.clientHeight) - 1);
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn