如何用Html,在图片上放按钮

html-css09

如何用Html,在图片上放按钮,第1张

有两种方法。

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

<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>

方法1:

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

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

方法2:

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

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

提示:需要把按钮的宽高设的和图片一样。