Posted: 2004/11月/16 1:19下午 | IP記錄
|
|
|
精確安置空白
在引入Cascading Style Sheet之前,要想控制一個網頁中的空白是非常困難的。使用下面的四個屬性:margin-left、margin-top、 margin-right和margin-bottom,一切就會變得很容易。表7.6顯示的例子說明了怎樣使用這四個屬性(見 圖7.34):
表7.6 控制文本空白
<HTML>
<HEAD> <TITLE> Style </TITLE>
<STYLE>
<!--
.Thin {margin-left: 50pt; margin-right: 50pt}
.VeryThin {margin-left: 100pt; margin-right: 100pt}
-->
</STYLE>
</HEAD>
<BODY>
<P CLASS=Thin>
Thin. Thin. Thin. Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin.
</P>
<P CLASS=VeryThin>
Very Thin. Very Thin. Very Thin. Very Thin. Very Thin.
Very Thin. Very Thin.
Very Thin. Very Thin. Very Thin. Very Thin. Very Thin.
Very Thin. Very Thin.
Very Thin. Very Thin. Very Thin. Very Thin. Very Thin.
Very Thin. Very Thin.
Very Thin. Very Thin. Very Thin. Very Thin. Very Thin.
Very Thin. Very Thin.
Very Thin. Very Thin. Very Thin. Very Thin. Very Thin.
Very Thin. Very Thin.
</P>
</BODY>
</HTML>
圖7.34 使用不同的空白
不需要一個個地指定空白值,你可以使用margin屬性來一次設定所有的空白值。當你使用margin屬性時,你需要依照top 、right、bottom和left的次序給出它們的值。如果你只提供了一個值,則它會提供給所有的四個屬性。如果你只提供了 兩個或三個值,其餘的值會從相對的位置去獲得。下面的例子說明了怎樣使用這個屬性:
<HTML>
<HEAD> <TITLE> Style </TITLE>
<STYLE>
<!--
.Thin {margin: 50pt}
-->
</STYLE>
</HEAD>
<BODY>
<P CLASS=Thin>
Thin. Thin. Thin. Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin. Thin. Thin. Thin.
Thin. Thin. Thin. Thin. Thin.
</P>
</BODY>
</HTML>
|