CSS:输入标签类中的大小属性

标签 css html-input

我有以下代码:

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

相关文章:

javascript - 从 css 到 Javascript 的输入 :focus {outline: none; }

javascript - chrome setSelectionRange() 在 oninput 处理程序中不起作用

javascript - 如何使用 javascript/jquery 在 span 中写入所有输入类型值?

jquery - 使用 JQuery 将两个输入框合并为一个

html - 将不可编辑的文本附加到输入末尾?

html - z-index 在表内不起作用

jquery - 仅使用两个元素对滚动条进行样式化

regex - 输入模式支持正则表达式的哪些变体?

CSS3 Ken Burn 效果在页面滚动时暂停,然后再次播放以获得流畅的动画效果

javascript - Jquery禁用文档缩放