プロが教える店舗&オフィスのセキュリティ対策術

z-index


あるページの気になる部分だけ切り取ってみました

他のコードで、

<html>
<head>

<title>aaa</title>

<style type="text/css">


div.left {
z-index: -100;
position: absolute;
top: 0px;
left: 0px;
width: 100px;
height: 100%;
background: "red";
}

div.right {
z-index: -100;
position: absolute;
top: 0px;
right: 0px;
width: 100px;
height: 100%;
background: "red";
}


</style>
</head>
<body>
<div class="left"></div>
<div class="right"></div>

</body>
</html>

z-index:-100;
とあるのですが、これはどういう意味ですか。

A 回答 (1件)

z軸座標です。

stacking context
 示されたソースは、多分知らない人がどこかを真似して書いたもの?通常-100なんてないだろう。

下記はサンプル(HTML4.01 Strict)
★Another HTML-lint gateway ( http://openlab.ring.gr.jp/k16/htmllint/htmllint. … )
★W3C CSS 検証サービス ( http://jigsaw.w3.org/css-validator/#validate_by_ … )
で検証済み
★下記HTMLは、視認性のため、タブを全角スペース2個で置換してある。元のタブに戻してテストすること。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
 <meta http-equiv="content-type" content="text/html; charset=Shift_JIS">
 <title>サンプル</title>
 <meta http-equiv="Content-Style-Type" content="text/css">
 <link rev="made" href="mailto:hoge@hoge.com" title="send a mail" >
 <style type="text/css">
<!--
 html,body{padding:0px;margin:0px;}
 h1{color:white;}
 body{ background-color:black;}
 p{z-index:1;
  background-color:red;position:absolute;width:400px;
  height:300px;top:100px;left:100px;
  font-size: 2em;
 }
 p+p{z-index:3;
  background-color:blue;
  top:200px;left:150px;
 }
 p+p+p{z-index:2;
  background-color:green;
  top:150px;left:200px;
 }
 p+p+p+p{z-index:-1;
  background-color:yellow;
  top:50px;left:250px;
 }
-->
 </style>

 <link rel="START" href="../index.html">
</head>
<body>
 <h1><a name="top">サンプル</a></h1>
 <p>・・1(red)stack level=1・・</p>
 <p>・・2(blue)stack level=3・・</p>
 <p>・・3(green)stack level=2・・</p>
 <p>・・4(yellow)stack level=-1・・</p>
</body>
</html>
「z-index」の回答画像1
    • good
    • 0
この回答へのお礼

詳しい解説ありがとうございました。
少しずつ勉強続けていくつもりなので、またよろしくお願いします。

お礼日時:2010/02/16 16:33

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!