DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> DIV十CSS布局 >> 布局實例
DIV 底部文字對齊技巧
編輯:布局實例     

CSS 沒有直接讓文字貼齊容器底部的屬性,但可以透過 position 的相對與絕對定位完成。

作法

讓父容器設定 position: relative,子元素設定 position: absolute,再用 bottom 指定距離。

#txt {
  position: relative;
  width: 300px;
  height: 300px;
  border: 1px solid #333;
  text-align: center;
}
#txt p {
  position: absolute;
  bottom: 0;
  padding: 0;
  margin: 0;
}

這樣段落文字就會貼近容器底部。若要保留一點間距,可將 bottom 設為 10px 或其他數值。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved