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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

CSS:<div>元素內(nèi)的中心元素

CSS:<div>元素內(nèi)的中心元素

九州編程 2019-12-16 09:49:47
CSS:<div>元素內(nèi)的中心元素要居中HTML元素,我可以使用CSS left: 50%;。但是,這使元素相對于整個窗口居中。我有一個元素,它是元素的子<div>元素,并且我想相對于此父元素而<div>不是整個窗口居中顯示該子元素。我不想容器<div>有所有的內(nèi)容為中心,只是一個特定的孩子。我怎樣才能做到這一點(diǎn)?
查看完整描述

3 回答

?
慕標(biāo)5832272

TA貢獻(xiàn)1966條經(jīng)驗(yàn) 獲得超4個贊

設(shè)置text-align:center;為父div和margin:auto;子div。


#parent {

    text-align:center;

    background-color:blue;

    height:400px;

    width:600px;

}

.block {

    height:100px;

    width:200px;

    text-align:left;

}

.center {

    margin:auto;

    background-color:green;

}

.left {

    margin:auto auto auto 0;

    background-color:red;

}

.right {

    margin:auto 0 auto auto;

    background-color:yellow;

}

<div id="parent">

    <div id="child1" class="block center">

        a block to align center and with text aligned left

    </div>

    <div id="child2" class="block left">

        a block to align left and with text aligned left

    </div>

    <div id="child3" class="block right">

        a block to align right and with text aligned left

    </div>

</div>

這是一個幾乎可以集中所有內(nèi)容的好資源。

http://howtocenterincss.com/


查看完整回答
反對 回復(fù) 2019-12-16
  • 3 回答
  • 0 關(guān)注
  • 466 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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