課程
/前端開發(fā)
/HTML/CSS
/初識HTML(5)+CSS(3)-升級版
怎么讓div中的div居中
2017-11-02
源自:初識HTML(5)+CSS(3)-升級版 13-6
正在回答
到div里面創(chuàng)建一個類名 然后寫一個<style> 到里面 .類名{ text-align:center;} 就行了
披薩書立外賣 提問者
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>div包含div居中</title>
<style type="text/css">
.div1{
? ? width:200px;
? ? height:200px;
border:1px red solid;
}
.div2{
? ? border:2px dashed red;
? ? width:50px;
? ? height:20px;
? ? margin-top:91px;<!--(200-20+2)/2-->
? ? margin-bottom:91px;
? ? margin-left:73px;<!--(200-50+2)/2-->
</style>
</head>
<body>
<div class="div1"><div class="div2">居中</div></div>
</body>
</html>
text-align 只是文字居中,層主問的是div中的div居中,你們試驗過沒有就亂說
類名{text-align:center}
div div{text-align:center;}
舉報
HTML(5)+CSS(3)基礎(chǔ)教程8小時帶領(lǐng)大家步步深入學(xué)習(xí)標(biāo)簽用法和意義
3 回答讓div居中
2 回答兩個div居中
3 回答如何實現(xiàn)div居中
1 回答給div居中沒有效果
3 回答如何使div中的文字居中
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2017-11-02
到div里面創(chuàng)建一個類名 然后寫一個<style> 到里面 .類名{ text-align:center;} 就行了
2017-12-10
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>div包含div居中</title>
<style type="text/css">
.div1{
? ? width:200px;
? ? height:200px;
border:1px red solid;
}
.div2{
? ? border:2px dashed red;
? ? width:50px;
? ? height:20px;
? ? margin-top:91px;<!--(200-20+2)/2-->
? ? margin-bottom:91px;
? ? margin-left:73px;<!--(200-50+2)/2-->
}
</style>
</head>
<body>
<div class="div1"><div class="div2">居中</div></div>
</body>
</html>
2017-12-10
text-align 只是文字居中,層主問的是div中的div居中,你們試驗過沒有就亂說
2017-11-02
類名{text-align:center}
2017-11-02
div div{text-align:center;}