<!DOCTYPE html><html><head><meta charset="UTF-8"><title>仿豆瓣</title><style>*{margin:0px;padding:0px;}a{text-decoration: none;}li{list-style-type:none;}img,input{ border:none; border:1px solid none;}#head{ width:1152px; height:88px; border:solid 1px red; margin:0px auto; position:relative;}#head .head-logo{background:url(../images/logo.png); display: block; width:158px;height:31px; position:absolute; left:0px; top:29px;}#head .head-search{ width:272px;height:32px; border:1px solid #c3c3c3; position:relative; left:185px;top:0px; color:#e4e4e4;}#head .test{ display: block; color:red; position:relative; left:0px; top:0px;}a {color:#d5e1e7; }a:hover{ background-color: #4b83af}</style></head><body> <div id = "head"> <a class="head-logo" href="#"></a> <form > <input type="text" class ="head-search" placeholder="書籍,電影,音樂,小組,小站,成員"/ > </form> <a class="test" href="#">123</a> </div> </body></html>
1 回答
已采納

千秋此意
TA貢獻(xiàn)158條經(jīng)驗(yàn) 獲得超188個(gè)贊
你兩個(gè)都給的relative,相對(duì)定位的元素不會(huì)脫離標(biāo)準(zhǔn)文檔流 所以飄不上去,相對(duì)定位是相對(duì)自身原來的位置定位 所以你給top:0和left:0相當(dāng)于保持原來我位置不變
添加回答
舉報(bào)
0/150
提交
取消