Html 如何将我的按钮变成图像按钮?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3766673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make my button into an Image button?
提问by 5416339
I have a default button. So now how do I make it a button image? So when you click on the button the normal thing happens. What I just want is an Image on the button. Thanks.
我有一个默认按钮。那么现在如何使它成为按钮图像?所以当你点击按钮时,正常的事情就会发生。我只想要按钮上的图像。谢谢。
采纳答案by Aryan G
You may try this:
你可以试试这个:
<INPUT TYPE="image" SRC="image location" ALT="SUBMIT">
回答by Sidharth Panwar
Try putting an image instead of a button and handle its onclick event.
尝试放置图像而不是按钮并处理其 onclick 事件。
回答by tjk
You can use an image as a button by specifying the srcproperty:
您可以通过指定src属性将图像用作按钮:
<input type="image" name="submit" value="submit" src="images/button.gif" />
回答by thomasmalt
you could try:
你可以试试:
<button style="display:block; background: url(/path/to/image.png) no-repeat center;">
Push me!
</button>
回答by Ashif Nataliya
you can use javascript with some logic.
您可以使用带有某种逻辑的 javascript。
create one button with style attribute style="display:block" also create required image just next to button with style="display:none"
创建一个样式属性为 style="display:block" 的按钮,并在样式为="display:none" 的按钮旁边创建所需的图像
onclick of button call javascript function.
onclick 按钮调用 javascript 函数。
function disphide()
{
btn.style.display='none';
img.style.display='block';
}
This should work
这应该工作