我正在設計Facebook登錄頁面爲練習。僅使用html和css.My問題是我想要定位.username,.password,submitButton類並排(如原始)。但該CSS不起作用。 這裏是我的html代碼定位div類
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Facebook- Log In or Sign Up</title>
<link rel="stylesheet" type="text/css" href="style.css" media="all"/>
</head>
<body>
<header class="mainHeader">
<div class="mainArea">
<div class="logoArea">
<img src="media/6cVHHozUQSt.png" alt=""/>
</div>
<div class="loginArea">
<form action="#">
<div class="userName">
<label for="user">Email or Phone </label> <br/>
<input type="text" id="user"/><br/>
<input type="checkbox" id="keepLogin"/>
<label for="keepLogin"> Keep me Logged In</label>
</div>
<div class="password">
<label for="password">Password </label>
<input type="password" id="password"/>
<a href="#">Forgotten you password?</a>
</div>
<div class="submitButton">
<input type="submit" value="Log In"/>
</div>
</form>
</div>
</div>
</header>
</body>
</html>
這裏是CSS
body{
margin:0;
padding:0;
}
header.mainHeader:after{
content:"";
display: block;
clear: both;
}
header.mainHeader{
background:#3a5797;
}
.mainHeader .logoArea{
width: 50%;
float: left;
}
.mainHeader .loginArea{
float:right;
width:50%;
}
.loginArea .username, .loginArea .password{
width: 40%;
float: left;
}
.loginArea .submitButton{
width: 20%;
float: left;
}
你嘗試的位置:相對和如果沒有工作,顯示:內聯塊與位置:相對? – ReadyFreddy