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

时间:2015-04-01    点击:172   

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

JS获取iframe中marginHeight和marginWidth属性的方法
JS去除iframe滚动条的方法
JS动态修改iframe内嵌网页地址的方法
JS获得图片alt信息的方法
JS实现动态给图片添加边框的方法
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved