日期:2014-05-16  浏览次数:20455 次

一个浮动DIV居中问题
不论滚动条滚动到什么位置,DIV总是居中,而且要兼容FF,这个怎样实现

谢谢

------解决方案--------------------
http://www.dynamicdrive.com/dynamicindex1/staticmenu.htm请你参考这个
------解决方案--------------------
http://shawl.qiu.googlepages.com/FixBox_v1.0.htm
------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=utf-8 " />
<title> shawl.qiu template </title>
<script type= "text/javascript " src= "FixBox_v1.0.js "> </script>
<script type= "text/javascript ">
// <![CDATA[
onload =
function()
{
var fixbox = new FixBox();

// fSetPosition(sX, sY, iWidth, iHeight, bDebug)
// sX: xleft, xcenter, xright
// xY: ytop, ymiddle, ybottom
fixbox.SetPosition( "xleft ", "ymiddle ", true, false, false);

fixbox.Body =
"by string1 <br/> by string2 <br/> by string3 <br/> by string4 <br/> by string5 <br/> "
+ "by string6 <br/> by string7 <br/> "
+ "by string8 <br/> by string9 <br/> by string10 <br/> "
+ " <!--by string11 <br/> by string12 <br/> by string13 <br/> by string14 <br/> --> "
;

//fixbox.Body = document.getElementsByTagName( "div ")[2];
fixbox.Go();
fixbox = null;

/*
var fixbox = new FixBox();

// fSetPosition(sX, sY, iWidth, iHeight, bDebug)
// sX: xleft, xcenter, xright
// xY: ytop, ymiddle, ybottom
fixbox.SetPosition( "xright ", "ytop ", false, false, true);

//fixbox.Body = document.getElementsByTagName( "div ")[2];
fixbox.Body = "byid ";

fixbox.Go();
fixbox = null;
*/
}
//]]>
</script>
</head>
<body>
<div id= "byid ">
by id
</div>
<div id= "byobject ">
by object
</div>
<div>
by set
</div> <br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br