在html里面怎么为一个按钮添加图片?

html-css08

在html里面怎么为一个按钮添加图片?,第1张

方法1:

给图片加一个onclick事件,用js事件来提交就可以实现。

例:<input type="image" src="图片地址" />

方法2:

有CSS把图片设为按钮背景就可以了

例: <input name="" type="button"  style=" width:10px height:10px  border:0 background:url(图片路径) no-repeat left top" />

有两种方法。

①:将图片做为背景,放上按钮。如:

<div style="width:100px height:100px background:url('1.jpg') 0 0 repeat">

    <input type="button" value="按钮" />

</div>

②:将按钮进行绝对定位,如:

<div style="position:relative">

    <img src="1.jpg" />

    <input type="button" value="按钮" style="position:absolute left:10px top:10px" />

</div>