CSS position:fixed fixed positioning div

Source: Internet
Author: User
Tags wrapper


First look at the ie7+, Firefox, Opera code:

The code is as follows Copy Code
<style type= "Text/css" >
#backTop {position:fixed; bottom:0; right:0;}
</style>

In IE6, you need some CSS hack to address it, and you need to add:

The code is as follows Copy Code
<!--[if IE 6]>
<style type= "Text/css" >
HTML {Overflow:hidden;}
body {height:100%; overflow:auto;}
#backTop {position:absolute;right:17px;}
</style>
<! [endif]-->

The absolute position of the ps:fixed element is relative to the HTML element, and the scroll bar is the BODY element, which is why the RIGHT:17PX is set

Further consideration of IE5.5 and the following versions:

The code is as follows Copy Code

<!--[If Lt IE 6]>
<style type= "Text/css" >
#backTop {position:absolute top:expression (eval (document.body.scrollTop + 50));}
</style>
<! [endif]-->


Instance

The code is as follows Copy Code

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<meta name= "Author" content= "Chomo"/>
<title> use of simulated position:fixed to do couplet </title>
<style>
* {padding:0; margin:0;}
body {height:100%; overflow:hidden; font-size:14px; line-height:2; position:relative;}
HTML {height:100%; overflow:hidden;}
. fixed {position:absolute; top:10px; left:50%; width:100px; margin-left:-490px; height:350px; background: #fc0; border : 1px solid #f60;}
. fixed2 {position:absolute; top:10px left:50%; width:100px; margin-left:370px; height:350px; background: #fc0; border : 1px solid #f60;}
. wrapper {height:100%; overflow:auto; overflow-y:scroll;}
. body {width:700px; margin:0 auto; background: #f2f2f2; padding:20px;}
</style>
<body>
<div class= "fixed" > Pig strong </div>
<div class= "Fixed2" > Another pig strong </div>
<div class= "wrapper" >
<div class= "Body" >
[Professional &raquo; industry watch] Rainbow show ip afraid into the defendant?  TX to the RAINBOW hint? Jarry 2008-11-17 <br/>
[Professional &raquo; industry observation] Shanghai East Building kappa Women: the role of the Internet = hype? Jarry 2008-11-13 <br/>
[Professional &raquo; Industry Watch] Global business networking platform: xing.com jarry 2008-11-1 <br/>
[Professional &raquo; Industry watch] What is Word-of-mouth marketing? Jarry 2008-10-17 <br/>
[Professional &raquo; industry observation] the opening of the second Open Web competition Jarry 2008-10-16 <br/>
[Professional &raquo; industry observation] Youa C2C Network trading platform will be online Jarry 2008-10-12 <br/>
[Professional &raquo; Industry watch] The first high-profile Google Android phone listing Jarry 2008-10-10 <br/>
[Professional &raquo; Industry watch] Seven black truths Jarry 2008-10-8 <br/> for subscribers
[Professional &raquo; industry observation] five necessary conditions to make money by blogging Jarry 2008-10-7 <br/>
[Professional &raquo; industry observation] Windows Live Messenger 9 Wave3 final release date determines Jarry 2008-10-6 <br/>
[Professional &raquo; industry observation] 2008 China Internet Conference opened yesterday Jarry 2008-9-24 <br/>
[Professional &raquo; industry observation] Youdao hot smell on-line! Jarry 2008-9-19 <br/>
[Professional &raquo; industry observation] Phpcms 2008 Beta September 1 Open source free release Jarry 2008-9-17 <br/>
[Professional &raquo; Industry watch] The Adobe AIR application Jarry 2008-9-10 <br/> Introduced by the computer newspaper
[Professional &raquo; industry observation] WordCamp 2008 is about to convene Jarry 2008-8-28 <br/>
[Professional &raquo; industry observation] The main steps to develop a hardware firewall Jarry 2008-8-11 <br/>
[Professional &raquo; Industry Watch] Count 20 windows 7 features that should be available-Windows 7 Home--iwindows7.com Jarry 2008-8-6 <br/>
[Professional &raquo; Industry watch] Internet operators and internet commentators Jarry 2008-6-22 <br/>
[Professional &raquo; Industry watch] interesting blogbus pause service hint Jarry 2008-6-12 <br/>
[Professional &raquo; Industry watch] who earns the most? Programmers earn big competition Jarry 2008-6-11 <br/>
[Professional &raquo; industry observation] The characteristics of blog marketing Jarry 2008-6-10 <br/>
[Professional &raquo; Industry observation] recommend an advertising platform in the text: Group view Jarry 2008-6-8 <br/>
[Professional &raquo; industry observation] Google official explains why to replace the small icon Jarry 2008-6-8 <br/>
[Professional &raquo; industry observation] 1GB Jarry 2008-6-8 <br/> 20 years ago
[Professional &raquo; industry observation] "pr=7, Sango, pr=8, harmony between heaven and Man" PR realm talk Jarry 2008-6-8 <br/>
[Professional &raquo; Industry watch] Big website lies, have you ever been cheated by Jarry 2008-6-8 <br/>
[Professional &raquo; industry observation] blog.35 free binding domain name WP service Jarry 2008-6-7 <br/>
[Professional &raquo; industry observation] Tencent SNS:QQ alumni began to Jarry 2008-6-7 <br/>
[Professional &raquo; industry observation] Measure blog value seven indicators Jarry 2008-6-6 <br/>
[Professional &raquo; industry observation] alternative thinking: Baidu is the client I (stationmaster) to learn to do Miss Jarry 2008-6-6 <br/>
[Professional &raquo; industry observation] China Telecom to undertake the operation strategy after CDMA Jarry 2008-6-5 <br/>
[Professional &raquo; Industry Watch] Microsoft new system Windows 7 Desktop screenshot (16pics) Jarry 2008-6-5 <br/>
[Professional &raquo; industry observation] 3G Portal: Wireless Internet portal Jarry 2008-6-5 <br/>
[Professional &raquo; industry observation] RETAGGR: Personalized business card making Jarry 2008-6-3 <br/>
[Professional &raquo; industry observation] Acrobat:adobe's network office Jarry 2008-6-3 <br/>
[Professional &raquo; industry observation] eight factors affecting the interactive operation of blogs Jarry 2008-6-2 <br/>
[Professional &raquo; Industry watch] 10 companies that influence Chinese communication habits Jarry 2008-6-2 <br/>
[Professional &raquo; Industry watch] May browser wars upgrade FireFox 3 Jarry 2008-6-2 <br/>
[Professional &raquo; Industry Watch] Why do many bloggers not make money? Jarry 2008-5-31 <br/>
[Professional &raquo; industry observation] VIA OpenBook Mini Notebook graphic Jarry 2008-5-31 <br/>
[Professional &raquo; Industry watch] human flesh search: Angel or Devil? Jarry 2008-5-30 <br/>
[Professional &raquo; industry observation] 360doc: Personal library, online collection Jarry 2008-5-30 <br/>
[Professional &raquo; industry observation] Time network: Movie, community, you and I jarry 2008-5-30 <br/>
[Professional &raquo; Industry watch] The top ten most annoying software Jarry 2008-5-27 <br/>
[Professional &raquo; Industry watch] paying employees to resign, Zappos's secret of success Jarry 2008-5-27 <br/>
[Professional &raquo; industry observation] three issued three 3G license plate Jarry 2008-5-25 <br/> After the announcement of the reorganization of telecom industry
[Professional &raquo; industry observation] QQ Network hard disk web version of the secret release Jarry 2008-5-25 <br/>
[Professional &raquo; industry observation] Google sites began opening its own personal homepage to everyone free of charge Jarry 2008-5-23 <br/>
[Professional &raquo; Industry watch] 10 unknown Google failed works Jarry 2008-5-22 <br/>
[Professional &raquo; industry observation] C2call: Network telephony service based on Web browsers Jarry 2008-5-21 <br/>
[Professional &raquo; Industry watch] Microsoft gives up Vista with Windows 7 instead of Jarry 2008-5-21 <br/>
[Professional &raquo; Industry watch] 2008 Web2.0 products Jarry 2008-5-21 <br/>
[Professional &raquo; industry observation] on Google earth to see the news Jarry 2008-5-21 <br/>
[Professional &raquo; industry observation] National day of mourning CCTV enable wenchuan.cn domain name Jarry 2008-5-20 <br/>
[Professional &raquo; Industry watch] Microsoft to contend with Google's plan: 20 billion acquisition of Facebook Jarry 2008-5-20 <br/>
[Professional &raquo; Industry watch] What's not to sell? -ebay Ten Mars auctions Jarry 2008-5-19 <br/>
[Professional &raquo; industry observation] Internet marketing-internet is the means, marketing is the essence Jarry 2008-5-13 <br/>
[Professional &raquo; industry observation] Mobile phone mailbox also plagiarism? Jarry 2007-11-2 <br/>
[Professional &raquo; industry observation]  Tnnd, want to completely give up MSN. Jarry 2007-6-11 <br/>
[Professional &raquo; Industry watch] Fun online tools Jarry 2006-11-11 <br/>
[Professional &raquo; industry observation] Let the toll site go to die, with Google Breakthrough!! Jarry 2005-11-20 <br/>
</div>
</div>
</body>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.