簡體   English   中英

與底部和水平居中對齊?

[英]Align to bottom and center horizontally?

我有一個模式,我希望頁碼在模式的底部並居中對齊。

頁碼的絕對位置是底部0,中間是文本對齊:

#pagination{

  background: blue;
  position: absolute;
  bottom: 0;
  width: 100%;
  text-align: center;  
}

問題是,我將頁碼設置為100%的寬度(以便它們可以居中對齊),但這要考慮到模式填充(我不能更改此設置),因此頁碼剛好偏離中心並偏離了頁。

小提琴

嘗試添加left:0; 給你的代碼

#pagination {
    background: none repeat scroll 0 0 blue;
    bottom: 0;
    left: 0;/*add this*/
    position: absolute;
    width: 100%;
}

像這樣的演示,添加left:0以及bottom:0position:absolute

CSS:

#pagination {
    background: blue;
    position: absolute;
    bottom: 0;
    width:100%;
    left:0;
}

而不是使用width:100%; 嘗試使用

#pagination{   
    background: blue;
    position: absolute;
    bottom: 0;
    left:0; 
    right:0;
}

這樣,如果需要,您可以在#pagination添加填充

將左右位置添加到0並刪除寬度CSS

#pagination{
left: 0;
right: 0;
}

http://jsfiddle.net/Csk6J/5/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM