Html 如何更改提交按钮的外观?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8814844/
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 change the submit button appearance?
提问by sasori
I have this plain submit button appearance in my html code
我的 html 代码中有这个简单的提交按钮外观
<input type="submit" name="pay now" value="pay" />
I wish to make the submit button look like this
我想让提交按钮看起来像这样
<a href="#"><img src="images/shopping-cart/check-out-btn.png" border="0" /></a>
but should stick with its submit type
但应该坚持其提交类型
how to do that ?
怎么做 ?
回答by Joseph Silber
You should use CSS for that:
您应该为此使用 CSS:
input[type="submit"] {
background: url(images/shopping-cart/check-out-btn.png);
width: 200px; /* width of image */
height: 50px; /* height of image */
border: 0;
}
You should probably use a more specific selector though.
不过,您可能应该使用更具体的选择器。
回答by Roel
A nice way to do this is using the button element.
一个很好的方法是使用按钮元素。
<button type="submit"><img src="images/shopping-cart/check-out-btn.png" border="0" /></button>
It works just like a regular input with type=submit, but you have much more freedom.
它就像使用 type=submit 的常规输入一样工作,但您有更多的自由。
回答by 0b10011
You can make an image into a submit
button by setting the type
attribute of the input
element to image
:
您可以submit
通过将元素的type
属性设置input
为image
:
<input type="image" src="/path/to/image.png">
For more information, read the image
Button State section of the HTML specification.
有关更多信息,请阅读image
HTML 规范的按钮状态部分。