+ -
当前位置:首页 → 问答吧 → 右侧DIV如何固定位置的呢?

右侧DIV如何固定位置的呢?

时间:2010-09-29

来源:互联网


<!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=gb2312" /> <title>右侧DIV如何固定位置的呢?</title> <link href="layout.css" rel="stylesheet" type="text/css" /> <style> body { font-family:Verdana; margin:0;text-align:center;} #container {margin:0 auto; width:900px;} #header { height:100px; background:#6cf; margin-bottom:5px; font-size:100px;} #main { height:500px; margin-bottom:5px;} #left { float:left; width:200px; height:800px; background:#9ff; font-size:140px;} #right { float:right; width:200px; height:1200px; background:#333; font-size:140px;color:#FFF} #content { margin:0 205px !important; margin:0 202px; height:2000px; background:#cff; font-size:90px;} </style> </head> <body> <div id="container"> <div id="header">这是头部</div> <div id="main"> <div id="left">这是左侧</div> <div id="right">这是右侧</div> <div id="content">这是中部</div> </div> </div> </body> </html>
 提示:您可以先修改部分代码再运行
如何写css使得右侧的div在随滚动条滚动到浏览器顶部时能够固定下来呢?

而反向滚动时,右侧的div有可以恢复到初始位置呢???

作者: iou33449999   发布时间: 2010-09-29

这个CSS恐怕实现不了了,用JS吧

作者: auror   发布时间: 2010-09-29