经常看到各大网站(例如:天涯,网易,阿里巴巴)的底部会有一个能够固定的漂浮条,该效果可以用js实现,但是今天新鲜代码站推荐一个纯css方法,更加简洁方便。
css代码如下:
body { background-image:url(text.txt); /* for IE6 */
background-attachment:fixed; }
#bottomNav { background-color:#096; z-index:999; position:fixed; bottom:0; left:0; width:100%; _position:absolute; /* for IE6 */
_top: expression(documentElement.scrollTop + documentElement.clientHeight-this.offsetHeight); /* for IE6 */ overflow:visible; }
html代码如下:
<div id="bottomNav">这里加入你的代码固定底部漂浮</div>
再看看这些需要注意的地方:
PS:你可能会对 text.txt 和 expression 感到郁闷,也有人使用多嵌套一层 DIV 做了个假滚动条实现了这个方法,当然这种方法在也会相应的改动下默认属性,可这种写法和之前网站融合起来很郁闷,要添加一个DIV(因为我之前没有在最外层写DIV.wrap)。