X Floater Fixed

Description

The floater finally got fixed!

This is a variation on the classic floater menu, but this menu doesn't float, it is fixed. For modern browsers it uses "position:fixed". For IE6 it simulates fixed positioning.

The technique used for simulating fixed positioning in IE is sometimes called the Catfish ;-)

There are two fixed elements on this page: fixedMenu and fixedPanel.

Implementation

Javascript is not required to fix the menu. Javascript is not required to simulate fixed positioning for IE6. However, this demo uses a little Javascript to do the following:

  • If "window.XMLHttpRequest" exists it assumes the browser supports fixed positioning and loads "floater_fixed.css".
  • Else if the browser is IE6 or less it will load "floater_fixed_ie6.css" which simulates fixed positioning for IE.
  • Else neither of the two CSS files will get loaded.

The following is the only Javascript used by this demo.

var addSS = false, ss = 'floater_fixed.css';
if (window.XMLHttpRequest) {
  addSS = true;
}
else {
  /*@cc_on
  @if (@_jscript_version < 5.7) // IE6 or down
  ss = 'floater_fixed_ie6.css';
  addSS = true;
  @end @*/
}
if (addSS) {
  var e = document.createElement('link');
  e.rel = 'stylesheet';
  e.type = 'text/css';
  e.href = ss;
  document.getElementsByTagName('head')[0].appendChild(e);
}

The following is "floater_fixed.css".

#fixedMenu {
  position:fixed;
  top:0; left:0;
  width:100%;
  overflow:hidden;
  visibility:visible;
  z-index:101;
}
#fixedPanel {
  position:fixed;
  top:0; right:0;
  width:150px;
  overflow:hidden;
  visibility:visible;
  z-index:100;
}

The following is "floater_fixed_ie6.css".

html, body {
  height:100%;
  width:auto;
  overflow:hidden;
  margin:0;
}
#fakeBody {
  position:relative;
  left:0; top:0;
  width:100%;
  height:100%;
  overflow:auto;
  padding:0;
  margin:0;
}
#fixedMenu {
  position:absolute;
  top:0; left:0;
  width:95%;

  overflow:hidden;
  visibility:visible;
  z-index:101;
}
#fixedPanel {
  position:absolute;
  top:0; right:16px;
  width:150px;
  overflow:hidden;
  visibility:visible;
  z-index:100;
}

But I must explain

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.

Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?

Sed ut perspiciatis

But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful.

Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?

Home  |  Forums  |  Library  |  Demos  |  Documentation  |  Downloads

Related Demos

Floater Box.

Floater Bar.

Floater Limited.

Vertical Toolbar.

Search

Cross-Browser.com

World Wide Web