我一直在尝试使用 CSS 更改按钮字体但未能成功。我可以更改它们的背景颜色,也可以更改 textarea 输入的字体,但由于某种原因,我似乎无法更改按钮的字体。根据我有限的理解,以下代码应该可以工作:
<html>
<head>
<style>
body {
font-family: monospace;
}
input[type=button] {
font-family: monospace;
}
</style>
</head>
<body>
This is a button:
<input type = "button" value = "Please click">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但只更改文本的字体,而不是按钮。我错过了什么?
[更新]每响应这里我改input [type = button]到input[type=button]。
小智 5
就这么简单,你已经拥有了。我认为您在编写 CSS 时犯了一个错误input[type=button],尽管您非常接近,但在 中有一个空格。
<style>
body {
font-family: monospace;
}
input[type=button] {
font-family: monospace;
}
</style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10958 次 |
| 最近记录: |