手机
当前位置:查字典教程网 >网页设计 > Div+Css教程 >css 固定顶部 怎么用css定义一个固定在页面顶部的层
css 固定顶部 怎么用css定义一个固定在页面顶部的层
摘要:CSS定义一个固定在页面顶部的层body{height:1200px;margin:0;padding:0;background-attac...

<!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>CSS定义一个固定在页面顶部的层</title>

<style type="text/css">

body {

height:1200px;

margin: 0;

padding: 0;

background-attachment: fixed; /* prevent screen flash in IE6 */

}

div,ul{margin: 0;padding: 0;}

#topNavWrapper {

width: 980px;

text-align: left;

height: 31px;

margin: 0px auto;

z-index:100;

_position: relative ;

_top:0px;

}

#topNav {

width: 980px;

float: left;

display: block;

z-index: 100;

overflow: visible;

position: fixed;

top: 0px; /* position fixed for IE6 */

_position: absolute;

_top: expression(documentElement.scrollTop + "px");

background-image: url( /uploadfile/2012/0717/0717014456145_4456.gif);

background-repeat: no-repeat;

background-position: right;

height: 31px;

line-height: 31px;

color:#fff;

background-color:#444;

text-align:center;

}

</style>

</head>

<body>

<div id="topNavWrapper">

<ul id="topNav">

我是固定在页面顶部的层

</ul>

</div>

</body>

</html>

【css 固定顶部 怎么用css定义一个固定在页面顶部的层】相关文章:

表格对决CSS

列元素所用属性之谜

css网页制作实用技巧9则

css返回顶部图标固定在浏览器右下角且兼容ie6

css教程:DIV布局网页的常见错误

正确使用CSS的height和min

Div+CSS布局入门教程

css的三种定位方式使用探讨

CSS兼容性问题 && CSS HACK

大型网站为什么把CSS直接写在页面里?

精品推荐
分类导航