2012年8月29日 星期三

css position設定

relative 相對於normal 即原來放的位置
z-index圖層設定,數字大者在最上層
<!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>
<style type="text/css">
div { border:1px solid black; }
.infront {
background-color:#ff9900;
width:100px;
height: 100px;
position:relative;
top:80px;
left:20px;
z-index: 2;
}
.behind {
background-color:#eeeeee;
width:100px;
height: 100px;
position:relative;
top:-30px;
left:20px;
z-index: 1;
}
</style>
<body>

<div class="infront">
In front
</div>
<div class="behind">
Behind
</div>

</body>
</html>
原位置

In front
Behind

改變後結果

In front
Behind


沒有留言:

張貼留言