2011年1月28日 星期五
2011年1月24日 星期一
CSS 的 left 屬性
今天在寫網頁列印,用 CSS 的 left 及 top 來定位文字的位子。
left 的語法︰設定元件左邊位置 ( 可設單位屬性 : 點 pt、英寸 in、公分 cm、像素 px、百分比 % )
top 的語法︰設定元件上方位置 ( 可設單位屬性 : 點 pt、英寸 in、公分 cm、像素 px、百分比 % )
一開始寫時用以下的寫法 ︰
position 的語法︰設定元件位置屬性 ( 可設絕對 absolute、相對 relative、靜態 static )
所以應用以下的寫法︰
left 的語法︰設定元件左邊位置 ( 可設單位屬性 : 點 pt、英寸 in、公分 cm、像素 px、百分比 % )
top 的語法︰設定元件上方位置 ( 可設單位屬性 : 點 pt、英寸 in、公分 cm、像素 px、百分比 % )
一開始寫時用以下的寫法 ︰
<div style='left: 4cm;top: 5cm;'>這是一個測試</div>都定位不出來,Google 了一下才發現,原來要使用 left 及 top 時要用 position 告訴 left 及 top 他們要對齊那裡的邊緣。
position 的語法︰設定元件位置屬性 ( 可設絕對 absolute、相對 relative、靜態 static )
所以應用以下的寫法︰
<div style=position:absolute;left: 4cm;top: 5cm;'>這是一個測試</div>
標籤:
筆記
訂閱:
文章 (Atom)