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

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


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/7319018.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-04
下一篇2023-04-04

发表评论

登录后才能评论

评论列表(0条)

    保存