学院首页>网页制作>Dreamweaver>Dreamweaver MX进阶教程(十二)在居中页面使用层

Dreamweaver MX进阶教程(十二)在居中页面使用层

作者:佚名 来源:不详 添加时间:2006-5-25 17:49:13
id="Layer1" style="position:absolute; left:45px; top:25px; width:400px; height:155px; z-index:1"></div>
层的相对定位代码:
<div id="Layer1" style="position: relative; left:45px; top:25px; width:400px; height:155px; z-index:1"></div>
在居中页面中,插入相对定位层代码,层的位置在页面居中。但是它变得不可移动,使用不够方便。
插入绝对定位代码,当left和top含有正负数值,层就无法居中。当清除left和top属性后,层可以居中,相对页面其它居中元素没有错位现象。

描绘层和插入层的差别
使用描绘层:

在一个居中的页面中,使用描绘层的代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>div</title>
</head>
<body>
<div id="Layer1" style="position:absolute; left:40px; top:30px; width:265px; height:75px; z-index:1"></div>
<div align="center"></div>
</body>
</html>
使用插入层:

在一个居中的页面中,使用插入层的代码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>div2</title>
</head>
<body>
<div align="center">
<div id="Layer1" style="position:absolute; width:200px; height:115px; z-index:1"></div>
</div>
</body>
</html>

因为使用“描绘层”生成的代码不在居中代码

之中,所以,在居中页面中,要使层相对其它元素没有错位现象,就必须使用插入层。

站内搜索