HTML DOM Image hspace 屬性
定義和用法
hspace 屬性可設置或者返回圖片的hspace 屬性值。
hspace 屬性指定圖像的左邊緣和右邊緣的空白。
語法
imageObject.hspace=pixels
瀏覽器支持
所有主要瀏覽器都支持hspace 屬性
實例
實例
下面的例子將設置圖像的hspace 和vspace 屬性:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function setSpace(){
document.getElementById("compman").hspace="50";
document.getElementById("compman").vspace="50";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif" alt="Computerman" width="107" height="98">
<p>一些文本。 一些文本。 一些文本。 一些文本。 </p>
<input type="button" onclick="setSpace()" value="設置水平和垂直間距">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function setSpace(){
document.getElementById("compman").hspace="50";
document.getElementById("compman").vspace="50";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif" alt="Computerman" width="107" height="98">
<p>一些文本。 一些文本。 一些文本。 一些文本。 </p>
<input type="button" onclick="setSpace()" value="設置水平和垂直間距">
</body>
</html>
嘗試一下»
Image對象