第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

第三種解決方案

#parent {

width: 200px;

height: 600px;

background: #ccc;

position: absolute;

}


#child {

width: 200px;

height: 200px;

background: #c9394a;

position: absolute; left: 0; top: 0; right: 0; bottom: 0;

margin: auto 0;


正在回答

4 回答

可以解釋一下嗎?不是很明白原理

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

ccyy_阿亮

定位元素在包含塊中的方程(垂直方向): top + margin-top + border-top-height + padding-top + height + padding-bottom + border-bottom-height + margin-bottom + bottom = the height of the containing block
2020-12-02 回復(fù) 有任何疑惑可以回復(fù)我~

測(cè)試了下,這樣就行啦,當(dāng)然,思路是你們的,我只是測(cè)試了下。。。?

#parent {

width: 200px;

height: 600px;

background: #ccc;

position: relative;

}


#child {

width: 200px;

height: 200px;

background: #c9394a;

position: absolute; top: 0; bottom: 0;?

margin: auto 0;


0 回復(fù) 有任何疑惑可以回復(fù)我~

第三種解決方案

<!DOCTYPE?html>

<html?lang="en">

<head>

??<meta?charset="UTF-8">

??<meta?name="viewport"?content="width=device-width,?initial-scale=1.0">

??<meta?http-equiv="X-UA-Compatible"?content="ie=edge">

??<title>測(cè)試</title>

??<style>


????.main{

??????width:100px;

??????height:500px;

??????background:?#666;

??????display:?flex;

??????align-items:?center;

????}

????.child?{

??????width:100px;

??????height:100px;

??????background:?red;

????}

??</style>

</head>

<body>

??<div?class="main">

????<div?class="child">

??????11111

??????1111111111

??????11111111111

??????11111111

??????</div>

??</div>

</body>

</html>


http://img1.sycdn.imooc.com//5def60f6000123b601600658.jpg

0 回復(fù) 有任何疑惑可以回復(fù)我~
#parent?{width:?200px;height:?600px;background:?#ccc;position:?relative;}#child?{width:?200px;height:?200px;background:?#c9394a;position:?absolute;?left:?0;?top:?0;?right:?0;?bottom:?0;margin:?auto;

這里應(yīng)該是margin:auto? ,不是 margin:auto 0;

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

第三種解決方案

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)