当前位置:Gxlcms > JavaScript > JS设置网页图片vspace和hspace属性的方法

JS设置网页图片vspace和hspace属性的方法

时间:2021-07-01 10:21:17 帮助过:3人阅读

本文实例讲述了JS设置网页图片vspace和hspace属性的方法。分享给大家供大家参考。具体分析如下:

hspace可以以像素为单位,指定图像左边和右边的文字与图像之间的间距;vspace 值则是上面的下面的文字与图像之间的距离的像素数

<!DOCTYPE html>
<html>
<head>
<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>Some text. Some text. Some text. Some text.</p>
<input type="button" onclick="setSpace()" 
value="Set hspace and vspace">
</body>
</html>

希望本文所述对大家的javascript程序设计有所帮助。

人气教程排行