使用CSS更改HTML按钮字体

使用CSS更改HTML按钮字体

本文介绍了使用CSS更改HTML按钮字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试并且未能使用CSS更改按钮字体.我可以更改其背景颜色,也可以更改textarea输入的字体,但是由于某些原因,我似乎无法更改按钮的字体.据我有限的理解,以下代码应该可以工作:

I've been trying and failing to change button font with CSS. I can change their background color and I can change a textarea input's font, but for some reason I don't seem to be able to change a button's font. From my limited understanding, the following code should work:

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

但仅更改文本的字体,而不更改按钮.我想念什么?

But only changes the font of the text, not the button. What am I missing?

[UPDATE]根据此处的回答,我将输入[type = button] 更改为 input [type = button] .

[UPDATE] Per the responses here I changed input [type = button] to input[type=button].

推荐答案

它是如此简单,您已经拥有了它.我认为您在编写CSS时犯了一个错误,尽管您很接近,但在 input [type = button] 中有一个空格.

It is so simple, you already have it. I think you made a mistake while writing CSS of it, you have a space in input[type=button], though you were pretty close.

<style>
body {
    font-family: monospace;
}
input[type=button] {
    font-family: monospace;

}
</style>

这篇关于使用CSS更改HTML按钮字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 11:00