HTML
<!DOCTYPE html>
<html>
<head>
<title>Learning</title>
</head>
<body>
...
<h1>Testing</h1>
<span class="error">* Required</span>
<form name="SignUp" method="post" action="">
<fieldset>
<div>
<label>Name:</label><input id="NAME" type="text" name="name" placeholder="Name" required>
</div>
<div>
<label>Email:</label><input id="EMAIL" type="email" name="email" required>
</div>
<div>
<label></label><input type="submit" value="Send" >
</div>
</fieldset>
</form>
</body>
</html>
CSS
body {
background-color:#b0c4de;
font-family:"Times New Roman";
font-size:15px;
}
p {color:blue;}
.error {color: #FF0000;}
label {
display: inline-block;
width: 150px;
text-align: right;
margin-right:30px; //How far the label element and input box
margin-top:100px;
}
fieldset{
//border:none;
padding:15px;
width:500px;
margin:0px auto;
}
Name: 和输入框在一行,下一行刚好碰到。
我怎么放它们apart .
最佳答案
向 div
添加一个 line-height
,如下所示:
div{
line-height: 30px;
}
注意: 在这里,我已经为 div
标签应用了一般的属性,因为它只是一个例子。在实际情况下,您可能希望为 fieldset
中的 div
标记添加一个 class
并应用 line-height
仅适用于该类(class)。这样做将确保页面中的其他 div
标签不受影响。
关于html - 如何在行(输入文本框和标签)之间插入垂直空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18891626/