Html 如何更改联系表单上的提交按钮字体
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17643061/
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 submit button font on contact form
提问by milcak
The 7th line from the end I tried to add in some CSS but it won't change the font on the button. Is there a way to do it in CSS or PHP? (Or maybe a way that actually works in HTML)
最后的第 7 行我尝试添加一些 CSS,但它不会更改按钮上的字体。有没有办法在 CSS 或 PHP 中做到这一点?(或者也许是一种在 HTML 中实际有效的方式)
Thanks in advance! I'm really new at this.
提前致谢!我真的很新。
here's my code:
这是我的代码:
<form name="htmlform" method="post" action="something_sendform.php">
<table width="450px">
</tr>
<tr>
<td valign="top">
<label for="first_name">First Name *</label>
</td>
<td valign="top">
<input type="text" name="first_name" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top"">
<label for="last_name">Last Name *</label>
</td>
<td valign="top">
<input type="text" name="last_name" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="email">Email Address *</label>
</td>
<td valign="top">
<input type="text" name="email" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="telephone">Telephone Number</label>
</td>
<td valign="top">
<input type="text" name="telephone" maxlength="30" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="comments">Comments *</label>
</td>
<td valign="top">
<textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea>
</td>
</tr>
<tr style="font-family:Orator Std">
<td colspan="2" style="text-align:center">
<input type="submit" value="Submit">
</td>
</tr>
</table>
</form>
回答by John WH Smith
Use the font-family
CSS property :
使用font-family
CSS 属性:
input[type=submit]{
font-family: 'Orator Std';
}
To be all-browsers compatible, add class="mysubmitbutton"
to your button, and use input.mysubmitbutton
instead of input[type=submit]
.
要与所有浏览器兼容,请添加class="mysubmitbutton"
到您的按钮,并使用input.mysubmitbutton
代替input[type=submit]
。
Edit :If you want to do this directly in the HTML code, do it on the input
tag :
编辑:如果您想直接在 HTML 代码中执行此操作,请在input
标记上执行此操作:
<input type="submit" value="Submit" style="font-family:'Orator Std';" />
I am not sure that Orator Std is a native CSS font though... For custom fonts usage in HTML/CSS, see this question.
不过,我不确定 Orator Std 是否是原生 CSS 字体...对于 HTML/CSS 中的自定义字体用法,请参阅此问题。
回答by Amal Murali
You're applying the styles on the wrong element. Try this:
您在错误的元素上应用了样式。尝试这个:
<input type="submit" value="Submit" style="font-family: sans-serif; font-size: 25px;">
Note that that Orator Std
is a custom font and if you want to use it, you'll have to download the font file and load it in your CSS using @font-face
.
请注意,这Orator Std
是一种自定义字体,如果要使用它,则必须下载字体文件并使用 .css 将其加载到 CSS 中@font-face
。
Also, using inline styles is generally regarded as a bad practice and it's best to apply the styles on input[type=submit]
in your CSS file or inside the <style>
tags. Thisquestion answers that in greater detail.
此外,使用内联样式通常被认为是一种不好的做法,最好input[type=submit]
在 CSS 文件或<style>
标签内应用样式。这个问题更详细地回答了这个问题。