CSS样式position属性的一个小实例:z方向三层布局分析
(编辑:jimmy 日期: 2024/11/26 浏览:3 次 )
CSS样式position的一个小实例代码如下:
复制代码代码如下:
<!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>CSS样式position的一个小实例:z方向三层布局-成功志(www.ok12.net)</title>
</head>
<body>
<div style="width:400px; height:400px; background:#666; border:#9FF 1px solid;margin:0 auto; color:#9FF ">
我是最底层
<div style="position:relative; background:#969;width:300px; height:300px; border:1px #fff solid ;margin:0 auto; margin-top:30px; color:#fff">
<div style="width:300px; height:300px; background:#099; margin:0 auto; ">我是中间层</div>
<div style="position:absolute; top:0; width:100px; height:100px; background:#CCF; margin:100px; color:#444; border:#444 1px solid">我是最顶层</div>
</div>
</div>
</body>
</html>
最终效果:
另一个示例:
复制代码代码如下:
<!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>另一个展示</title>
</head>
<body>
<div style="width:220px; height:220px;background:#369; padding:10px">
<div style="position:relative;margin:10px;">
<div style="background:#CCC; width:200px; height:200px; "></div>
<div style="background:#666; width:180px; height:180px; position:absolute; top:0; margin:10px">
<div style="width:160px; height:160px; background:#f00; margin:10px"></div></div>
</div>
</div>
<div><embed src="/UploadFiles/2021-03-30/qplayer_rtmp.swf?XNDQ1NzEzNjgw&winType=adshow&isAutoPlay=true"></body>
</html>
复制代码代码如下:
<!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>CSS样式position的一个小实例:z方向三层布局-成功志(www.ok12.net)</title>
</head>
<body>
<div style="width:400px; height:400px; background:#666; border:#9FF 1px solid;margin:0 auto; color:#9FF ">
我是最底层
<div style="position:relative; background:#969;width:300px; height:300px; border:1px #fff solid ;margin:0 auto; margin-top:30px; color:#fff">
<div style="width:300px; height:300px; background:#099; margin:0 auto; ">我是中间层</div>
<div style="position:absolute; top:0; width:100px; height:100px; background:#CCF; margin:100px; color:#444; border:#444 1px solid">我是最顶层</div>
</div>
</div>
</body>
</html>
最终效果:
另一个示例:
复制代码代码如下:
<!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>另一个展示</title>
</head>
<body>
<div style="width:220px; height:220px;background:#369; padding:10px">
<div style="position:relative;margin:10px;">
<div style="background:#CCC; width:200px; height:200px; "></div>
<div style="background:#666; width:180px; height:180px; position:absolute; top:0; margin:10px">
<div style="width:160px; height:160px; background:#f00; margin:10px"></div></div>
</div>
</div>
<div><embed src="/UploadFiles/2021-03-30/qplayer_rtmp.swf?XNDQ1NzEzNjgw&winType=adshow&isAutoPlay=true"></body>
</html>
下一篇:css 固定顶部 怎么用css定义一个固定在页面顶部的层