我有以下代码:
<!doctype html>
<html>
<head>
<title>Rich Home</title>
<meta charset="utf-8">
<style>
body { background-color: Black; color: White; }
h1 {text-align: center}
.st{ color: Green; background-color: Yellow; size: "80"; type:"text" }
</style>
</head>
<body>
<h1>Rich's Home Page</h1>
<form action="https://google.com/search" method="get">
Google: <input class=st name="q" autofocus>
<input type="submit" value="=>">
</form>
<form action="https://duckduckgo.com" method="get">
Duck: <input class=st name="q">
<input type="submit" value="=>">
</form>
</body>
</html>
我在 Firefox、Chrome 和 Chromium 中打开过。 color 和 background-color 应用于两个输入框,但 size 没有。这是为什么?
根据各种答案评论进行编辑。使用以下行无效:
.st{ color: Green; background-color: Yellow; width: "600px"; type:"text" }
最佳答案
CSS 中没有“大小”属性。它是标记属性。 如果您想使用 CSS 指定元素的宽度或高度 - 使用:
.st {
width: 80px;
}
并且您不能使用 CSS 设置元素类型。改为设置属性:
<input class=st name="q" type="text" autofocus>
您还可以使用属性指定宽度:
<input class=st name="q" type="text" width="50" autofocus>
关于CSS:输入标签类中的大小属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44046908/