2009-08-03 75 views
1

是否有可能有一箇中心對齊(即)總是我需要在底部中心的固定位置在指定的寬度。我知道它有左還是右?有什麼辦法嗎?是否有可能使div底部中心與寬度一致?

+2

嘗試採取一看這個問題的答案非常類似的問題:http://stackoverflow.com/questions/1042209/how-to-center-my-a-div-in-a-table-using-css/1042216#1042216 – 2009-08-03 07:41:23

+0

此外,定義「底部」 - 可見的底部窗格?立即在所有內容下面?在可見窗格的底部,除非內容低於該範圍?這個問題的核心部分很容易回答,但如果沒有澄清,整個問題可能無法令人滿意地回答。 – 2009-08-03 07:50:18

回答

14

我想這可能會幫助你

CSS:我

#parent{ 
    position:fixed; 
    bottom:0px; 
    width:100%; //width should be 100% 
} 
#child{ 
    width:100px; //min width should give to center the div. 
    margin:0px auto; //here it will make center 
}  

HTML

<div id='parent'> 
    <div id='child'> 
     centered div 
    </div> 
</div> 
1
.myDiv 
{ 
    position: fixed; 
    bottom: 0px; 
    width: 200px; 
    margin-left: auto; 
    margin-right: auto; 
} 
0

其他的答案沒有工作,但這裏是沒有溼婆的輕微修改回答。有父子DIV組合,其中一個抓住頁面的底部,另一個抓住中心 像這樣

.bottomOfThePage{ 
    position:fixed; 
    bottom:0px; 
    width:100%; 
} 
.centerOfThePage{ 
    text-align: center; 
    //other text stuff like color 
} 

HTML

<div class="bottomOfThePage"> 
    <div class="centerOfThePage"> 
     <p>footerStuffHere</p> 
    </div> 
</div> 
相關問題