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


本文实例讲述了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程序设计有所帮助。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3