简体   繁体   English

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

[英]Unable to change height of input:type=“submit” button

The code: 编码:

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

I am trying to make the input:type="submit" button the same height as the labels for the hours, minutes and seconds boxes i have created. 我正在尝试input:type="submit"按钮与我创建的小时,分​​钟和秒框的标签高度相同。 However i can only change the width of the button, not the height. 但是我只能改变按钮的宽度,而不是高度。 How can i make the height the exact same as the labels? 如何使高度与标签完全相同? Thanks. 谢谢。

Button includes the padding and the border attributes by default. 按钮默认包含填充和边框属性。 You can just add box-sizing: content-box; 你可以添加box-sizing: content-box; to the button. 到按钮。

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

Here is the fiddle 这是小提琴

Button should be 86px height: 按钮应为86px高度:

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

It is happening because the height of the button is including the paddings and the border. 它正在发生,因为按钮的高度包括填充和边框。 86px is the whole height of the button. 86px是按钮的整个高度。

Please update the #button id with the box-sizing attribute. 请使用box-sizing属性更新#button id。 Please Click here to see resolved issue. 请点击此处查看已解决的问题。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM