課程
/前端開發(fā)
/HTML/CSS
/初識(shí)HTML(5)+CSS(3)-升級(jí)版
固定定位后怎么才能讓div1 居中呢?
不固定定位就可以居中,該怎么破啊大神們
2016-04-17
源自:初識(shí)HTML(5)+CSS(3)-升級(jí)版 13-8
正在回答
div{
height:60px;
? ? width:150px;
? ? line-height:60px;
background:#ccc;
? ? position:fixed;
? ? margin:auto;
? ? left:0;
? ? right:0;
? ? top:0;
? ? bottom:0;
}
只左右居中,去掉top bottom =0
只上下居中,去掉left righr = 0
注意:要限制height和width ?否則也不會(huì)居中
echojson 提問(wèn)者
div1{text-align:center;}
舉報(bào)
HTML(5)+CSS(3)基礎(chǔ)教程8小時(shí)帶領(lǐng)大家步步深入學(xué)習(xí)標(biāo)簽用法和意義
2 回答層模型--固定定位
5 回答層模型的固定定位
5 回答層模型--固定模型
1 回答層模型--相對(duì)定位
4 回答層模型—絕對(duì)定位
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-04-17
div{
height:60px;
? ? width:150px;
? ? line-height:60px;
background:#ccc;
? ? position:fixed;
? ? margin:auto;
? ? left:0;
? ? right:0;
? ? top:0;
? ? bottom:0;
}
只左右居中,去掉top bottom =0
只上下居中,去掉left righr = 0
注意:要限制height和width ?否則也不會(huì)居中
2016-04-17
div1{text-align:center;}