ボックスの位置を指定する


top: ***; right: ***; bottom: ***; left: ***;

ブラウザ
Internet Explorer Netscape Firefox Opera
参考
書式基本 要素名 クラス ID

toprightbottomleft は、ボックスの表示位置を指定するプロパティです。

この表示位置の指定は、position プロパティで relativeabsolutefixed を指定している場合に有効です。


div {
position: absolute;
top: 10px;
left: 30%;
}


top 上からの距離を指定します
right 右からの距離を指定します
bottom 下からの距離を指定します
left 左からの距離を指定します

それぞれ 数値+単位(px、他)か %(割合)で指定します。

※デフォルトは auto(自動)です。(例:left: auto


使用例

<html>
<head>
<title>TAG index Webサイト</title>

<style type="text/css">
<!--

div {
width: 300px;
height: 100px;
background-color: #85b9e9;
position: absolute;

}

#example1 {
top: 50px;
left: 150px;
}
#example2 {
top: 200px;
left: 50px;
}


-->
</style>

</head>
<body>

<div id="example1">ボックス1</div>
<div id="example2">ボックス2</div>

</body>
</html>

これをブラウザで見ると次のように表示されます



[特集] レンタルサーバー比較 & サーバー選びのチェックポイント
[統計] HTMLからXHTMLへの移行を進めていますか?