我希望我的標籤顯示位於文本字段中,這裏是我準確要求他們的截圖http://s20.postimg.org/p8h11xrot/label_1.png。 我真的不知道該怎麼做,我嘗試了text-align
或float: left
。從文本字段左上角顯示標籤
這是我的CSS文件:
body {
}
#container{
background-color:#ccccff;
width:100%;
margin-left:auto;
margin-right:auto;
}
.content {
padding: 5px;
width:100%;
margin-left:auto;
margin-right:auto;
text-align:center;
}
label {
text-align: center;
}
article p{
text-align:center;
}
header{
width: auto;
height: 100px;
background-color: #ffffff;
background: url(image.png) center center no-repeat;
text-align:center;
}
footer{
text-align:center;
background-color: #999999;
}
的Index.html
<!DOCTYPE html>
<html>
<head>
<title>Intes - Register</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<header> Header Image </header>
<section id="container">
<article><p>Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Sed eget vehicula sapien.
Donec vitae quam id dolor pretium viverra.
Nulla viverra quam eget fringilla ultrices.</article>
<label>First Name</label>
<br />
<div class="content">
<input type="text" name="first_name" size="50">
<br />
</div>
<label>Last Name</label>
<br />
<div class="content">
<input type="text" name="last_name" size="50">
<br />
</div>
<label>E-mail Address</label>
<br />
<div class="content">
<input type="text" name="email_address" size="50">
<br />
</div>
<div class="content">
<input type="submit" value="Register">
</div>
</section>
<footer>copyright stuff</footer>
</body>
</html>
你嘗試使用'的text-align:left'? –
是的,我嘗試過,但他們出現在頁面的左側,而不是在文本字段的頂部 – FBC