Image hspaceプロパティ
Image オブジェクト
定義と使い方
hspace プロパティは、画像の hspace 属性値を設定または返します。
hspace 属性は、画像の左端と右端の余白を指定します。
構文
imageObject.hspace=pixels
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザは hspace プロパティをサポートしています。
例
例
次の例は、画像の hspace プロパティと vspace プロパティを設定します。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>初心者向けチュートリアル(example.com)</title>
<script>
function setSpace(){
document.getElementById("compman").hspace="50";
document.getElementById("compman").vspace="50";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif.html" alt="Computerman" width="107" height="98">
<p>テキスト。テキスト。テキスト。テキスト。</p>
<input type="button" onclick="setSpace()" value="水平および垂直の間隔を設定">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>初心者向けチュートリアル(example.com)</title>
<script>
function setSpace(){
document.getElementById("compman").hspace="50";
document.getElementById("compman").vspace="50";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif.html" alt="Computerman" width="107" height="98">
<p>テキスト。テキスト。テキスト。テキスト。</p>
<input type="button" onclick="setSpace()" value="水平および垂直の間隔を設定">
</body>
</html>
試してみる »
Image オブジェクトその他の拡張