<!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貢獻158條經驗 獲得超188個贊
你兩個都給的relative,相對定位的元素不會脫離標準文檔流 所以飄不上去,相對定位是相對自身原來的位置定位 所以你給top:0和left:0相當于保持原來我位置不變
- 1 回答
- 0 關注
- 1086 瀏覽
相關問題推薦
添加回答
舉報
0/150
提交
取消