在项目上工作,出于一些神秘的原因,我的输入框上方的边距已经很高了。
.header {
height: 100px; width: 100%;
background-color: #ef5fc2;
position: relative; color: white;
}
.header p {
position: relative; top: 25px;
margin-top: 0;
}
body {
font-family: 'Itim', cursive;
font-size: 40px;
margin: 0px; padding: 0px;
text-align: center;
background-color: pink;
}
body form p {
font-size: 18px;
}
.container {
height: 700px;
}
.footer {
background-color: red;
color: white;
height: 70px;
width: 100%;
}
.footer p {
font-size: 20px;
padding: 0px;
margin: 0px;
}
.footer p:first-child {
padding-top: 10px;
}
.container form p {
margin-bottom: 0;
padding: 0;
}
form input {
margin-top: 0;
padding: 0;
}
form {
position: relative;
top: 30px;
}
#submitbtn {
position: relative;
border: 5px solid #ff3385;
border-radius: 6px;
background-color: #ff3385;
padding: 5px 10px;
text-decoration: none;
color: white;
}
.submitContainer {
height: 50px;
margin-bottom: 20px;
}
#agreement {
font-size: 20px;
width: 320px;
top: 300px;
position: absolute;
left: 120px;
text-align: left;
border: 2px solid red;
padding: 10px 20px;
}
<form>
<p>Your first name</p>
<input type="text" name="first name" value="">
<p>Your last name</p>
<input type="text" name="last name" value="">
<p>Your address (inc. zip/post code)</p>
<input id="userAddress" class="addressBox" type="text" name="address box" value="">
<p>Your date of birth</p>
<input type="text" name="date of birth" value="">
<p>Your email</p>
<input type="email" name="email" value="">
<p>Your cell phone number</p>
<input id="marginBottom" type="number" name="phone number" value="">
</form>
当我偷看Chrome中的开发人员工具并仔细查看边缘和填充突出显示工具,在那里我有额外的边距,它没有显示任何有用的东西。它只是从p
标记直接跳到input
标记,而不承认不必要的差距。它确实承认p
标签上方的边距,但那些不会让我感到烦恼。
有什么想法吗?
答案 0 :(得分:1)
这个差距是由身体的import { Component } from '@angular/core';
@Component({
selector: 'map-component',
template: `
<div class="map">
<h4>My message about the map</h4></div>
`,
styles: [
height: 100%;
width: 100%;
background-color: grey;
]
})
export class MapComponent {}
引起的,现在变为16px
我还将font-size: 40px
更改为p
并将label
给了他们,以便他们突破。
现在您可以使用输入和标签
上的边距来调整间隙如评论中所述,名称属性中不应有空格,因此我将其删除
display: block
.header {
height: 100px;
width: 100%;
background-color: #ef5fc2;
position: relative;
color: white;
}
.header p {
position: relative;
top: 25px;
margin-top: 0;
}
body {
font-family: 'Itim', cursive;
font-size: 16px;
margin: 0px;
padding: 0px;
text-align: center;
background-color: pink;
}
body form label {
font-size: 18px;
display: block;
}
.container {
height: 700px;
}
.footer {
background-color: red;
color: white;
height: 70px;
width: 100%;
}
.footer p {
font-size: 20px;
padding: 0px;
margin: 0px;
}
.footer p:first-child {
padding-top: 10px;
}
.container form a {
margin-bottom: 0;
padding: 0;
}
form input {
margin: 0 0 10px;
padding: 0;
}
form {
position: relative;
top: 30px;
}
#submitbtn {
position: relative;
border: 5px solid #ff3385;
border-radius: 6px;
background-color: #ff3385;
padding: 5px 10px;
text-decoration: none;
color: white;
}
.submitContainer {
height: 50px;
margin-bottom: 20px;
}
#agreement {
font-size: 20px;
width: 320px;
top: 300px;
position: absolute;
left: 120px;
text-align: left;
border: 2px solid red;
padding: 10px 20px;
}
答案 1 :(得分:1)
了解页面边距和间距的最佳方法是使用浏览器的inspect元素功能。只需单击其中一个文本框或空格,它将给出相应的元素。
你可以编辑它