search
HomeWeb Front-endJS TutorialJavaScript ie6 compatible position:fixed implementation ideas_javascript skills

positon:fixed allows the HTML element to be separated from the document flow and fixed at a certain position in the browser
There are often floating navigation bars in web pages that use this positioning mode, but this positioning is not compatible with IE6
Floating The important thing about the style of the navigation bar is position: fixed; bottom: 60px; (the bottom of the floating navigation is 60px from the bottom of the window)

Copy code The code is as follows:

.floating_9677{position:fixed; z-index:961; bottom:60px;}

positon:fixed does not work under ie6, only It can be achieved with js. First, under ie6, you need to set the position to absolute
Copy the code The code is as follows:

position:fixed;bottom:60px;_position:abosulte;

Add an attribute identifier to the floating elements, and js can find these floating elements through this attribute. tag="floatNavigator"
At work, the floating navigation bar is mainly positioned through top or bottom.
Copy code The code is as follows:

//ie6 compatible position: fixed
function fixedPositionCompatibility (){
//Determine whether the ie6 browser is
if( $.browser.msie || parseInt($.browser.version,10) var vavigators = $(" [tag='floatNavigator']");
if(!navigators.length)return;
//Judge whether each floating layer is fixed at the top or at the bottom
$.each(navigators, function( ){
this.top = $(this).css("top");
this.bottom = $(this).css("bottom");
this.isTop = this.top == "auto" ? false : true;
});
window.attachEvent("onscroll", function(){
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
$.each(navigators, function(){
this.style.top = this.isTop ? scrollTop parseInt(this.top) "px" : scrollTop $(window).height() - $(this ).outerHeight() - parseInt(this.bottom) "px";
});
});
}
}
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
H5中position属性的灵活运用技巧H5中position属性的灵活运用技巧Dec 27, 2023 pm 01:05 PM

H5中如何灵活运用position属性在H5开发中,经常会涉及到元素的定位和布局问题。这时候,CSS的position属性就会发挥作用。position属性可以控制元素在页面中的定位方式,包括相对定位(relative)、绝对定位(absolute)、固定定位(fixed)和粘附定位(sticky)。本文将详细介绍在H5开发中如何灵活运用position属性

html怎样把div放在底部html怎样把div放在底部Mar 02, 2021 pm 05:44 PM

html把div放在底部的方法:1、使用position属性将div标签相对于浏览器窗口进行定位,语法“div{position:fixed;}”;2、设置到底部距离为0来把div永远放置于页面底部,语法“div{bottom:0;}”。

CSS 布局属性优化技巧:position sticky 和 flexboxCSS 布局属性优化技巧:position sticky 和 flexboxOct 20, 2023 pm 03:15 PM

CSS布局属性优化技巧:positionsticky和flexbox在网页开发中,布局是一个非常重要的方面。良好的布局结构可以提高用户体验,使页面更加美观和易于导航。而CSS布局属性则是实现这一目标的关键。在本文中,我将介绍两种常用的CSS布局属性优化技巧:positionsticky和flexbox,并提供具体的代码示例。一、positions

h5如何使用positionh5如何使用positionDec 26, 2023 pm 01:39 PM

在H5中使用position属性可以通过CSS来控制元素的定位方式:1、相对定位relative,语法为“style="position: relative;”;2、绝对定位absolute,语法为“style="position: absolute;”;3、固定定位fixed,语法为“style="position: fixed;”等等。

position有哪些属性position有哪些属性Oct 10, 2023 am 11:18 AM

position属性取值有static、relative、absolute、fixed和sticky等。详细介绍:1、static是position属性的默认值,表示元素按照正常的文档流进行布局,不进行特殊的定位,元素的位置由其在HTML文档中的先后顺序决定,无法通过top、right、bottom和left属性进行调整;2、relative是相对定位等等。

CSS中sticky定位属性的用法和效果展示CSS中sticky定位属性的用法和效果展示Dec 27, 2023 pm 12:08 PM

CSS中的position属性应用实例:sticky定位的使用方法和效果在前端开发中,我们经常使用CSS的position属性来控制元素的定位。其中,position属性有四个值可选:static、relative、absolute和fixed。而在这些常见的位置属性之外,还有一种特殊的定位方式,即sticky定位。本文将探讨sticky定位的使用方法和效果

CSS 层叠属性解读:z-index 和 positionCSS 层叠属性解读:z-index 和 positionOct 20, 2023 pm 07:19 PM

CSS层叠属性解读:z-index和position在CSS中,布局和样式的设计是非常重要的。而在设计中,经常需要对元素进行层叠和定位。两个重要的CSS属性,即z-index和position,可以帮助我们实现这些需求。本文将深入探讨这两个属性并提供具体的代码示例。一、z-index属性z-index属性用于定义元素在垂直方向上的堆叠顺序。元素的层叠

HTML布局技巧:如何使用position属性进行浮动元素控制HTML布局技巧:如何使用position属性进行浮动元素控制Oct 21, 2023 am 09:22 AM

HTML布局技巧:如何使用position属性进行浮动元素控制在网页设计中,布局是非常重要的一环。通过合理的布局可以使网页更加美观、易读,提升用户体验。而在实现布局过程中,浮动元素的控制是其中一个关键点。HTML提供了position属性,通过这个属性我们可以实现对浮动元素的控制。本文将介绍如何使用position属性进行浮动元素的布局,并提供一些具体的代码

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

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.

DVWA

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 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft