无法更改输入的高度:type =“submit”按钮

时间:2015-10-24 06:45:44

标签: html css button height

代码:

<!DOCTYPE html>
<html>
<head>
<title>Set Alarm Clock</title>
<style type="text/css">
#container {
width: 600px;
height: 300px;
border: 1px solid black;
}
#hours, #minutes, #seconds {
width: 120px;
height: 80px;
}
#button {
width: 120px;
height: 80px;
}
</style>
</head>
<body>
<center>
<div id="container">
<h1>Set Alarm Clock</h1><br />
<label class="hours">
<input type="number" value="0" min="0" id="hours" />
</label>
<label class="minutes">
<input type="number" value="0" min="0" id="minutes" />
</label>
<label class="seconds">
<input type="number" value="0" min="0" id="seconds" />
</label>
<label>
<input type="submit" value="Set Alarm" id="button" />
</label>
</div>
</center>
</body>
</html>

我正在尝试使input:type="submit"按钮与我创建的小时,分​​钟和秒框的标签高度相同。但是我只能改变按钮的宽度,而不是高度。如何使高度与标签完全相同?感谢。

3 个答案:

答案 0 :(得分:0)

按钮默认包含填充和边框属性。 您只需将box-sizing: content-box;添加到按钮即可。

#button {
width: 120px;
height: 80px;
box-sizing: content-box;
}

以下是fiddle

答案 1 :(得分:0)

按钮应为86px高度:

#button {
    width: 120px;
    height: 86px;
}

这是因为按钮的高度包括填充和边框。 86px是按钮的整个高度。

答案 2 :(得分:0)

请使用#button属性更新box-sizing ID。请点击here查看已解决的问题。

#button {
  width: 120px;
  height: 80px;
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
}