CSS:为什么只有第一个元素高度不同?

时间:2013-02-18 21:40:10

标签: css

这里:URL第一个字段是40px高而其他所有字段都是30px。我不知道怎么可能。

我想:

  • 纠正&了解问题
  • 使所有字段“垂直对齐”(标签不是垂直居中的)。

任何帮助都非常感谢!

2 个答案:

答案 0 :(得分:0)

在回答第二个问题时,请为标签添加等于旁边输入的line-height。你也可以尝试:

position: relative;
top: 50%;
bottom: 50%;
line-height: 0;

更一般的风格。只需将其应用于.labels或其他内容,而不是单独设置每个样式。

答案 1 :(得分:0)

来自bootstrap的以下css会在输入下方添加10px的边距:

select, textarea, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"], .uneditable-input {
  height: 20px;
  padding: 4px 6px;
  margin-bottom: 10px;
}

我删除了东西但是20px高度加上8px垂直填充,2px用于边框,10px边距底部意味着这将具有40px总高度。

覆盖此样式,但为此特定元素添加margin: 0