2
我試圖將元素放在標題的末尾。我正在使用所見即所得的設計器。在設計師中,這是我想要的,但在瀏覽器上,元素不在我想要的位置。這裏是代碼:CSS-Place元素在div末尾
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Home</title>
<style type="text/css">
#header
{
background-color:#FF6600;
height: 151px;
width:100%;
}
#title
{
z-index: 1;
left: 20px;
top: 32px;
position: absolute;
height: 47px;
width: 353px;
color:White;
font-size:48px;
font-family:Consolas;
}
#motto
{
z-index: 1;
left: 21px;
top: 103px;
position: absolute;
height: 42px;
width: 381px;
right: 951px;
font-size:20px;
color:White;
}
div
{
font-family:Consolas;
width: 121px;
}
#txtUserName
{
z-index: 1;
left: 1083px;
top: 23px;
position: absolute;
width: 250px;
height: 30px;
}
#txtPassword
{
z-index: 1;
left: 1082px;
top: 65px;
position: absolute;
width: 250px;
height: 30px;
}
#btnLogin
{
z-index: 1;
left: 1082px;
top: 107px;
position: absolute;
width: 250px;
height: 30px;
background-color:Black;
color:White;
font-family:Consolas;
font-size:20px;
}
</style>
</head>
<body style="background-color:#F5F5F5; height: 748px;">
<div id="header">
<div id="title">
My Webpage
</div>
<div id="motto">
Home
</div>
<input id="txtUserName" type="text" />
<input id="txtPassword" type="text" />
<input id="btnLogin" type="submit" value="Login" />
</div>
</body>
</html>
我想把元素在標題的結尾,但我不能。我知道這是因爲我使用絕對定位,但我不知道如何解決它。感謝幫助。
哪些元素是我們談論的是一個預覽?順便說一句,這裏是[小提琴](http://jsfiddle.net/MrLister/c5o3wywc/)。 –
絕對定位是佈局網頁的非常糟糕的方法。它非常不靈活,並且有更好更快的響應選項。試試[** LearnLayout.com **](http://learnlayout.com/) –
你爲什麼使用所見即所得的設計師? –