HtmlImage.Align 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定圖片相對於其他網頁元素的對齊。
public:
property System::String ^ Align { System::String ^ get(); void set(System::String ^ value); };
public string Align { get; set; }
member this.Align : string with get, set
Public Property Align As String
屬性值
一個字串,用來指定圖片相對於其他網頁元素的對齊方式。
範例
以下程式碼範例示範如何利用該 Align 屬性指定網頁上圖片的對齊方式。
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlImage Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HtmlImage Example</h3>
<img id ="Image1"
src="Image1.jpg"
alt="Image 1"
runat="server"
style="width:500; height:226; border:5; text-align:center" />
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlImage Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HtmlImage Example</h3>
<img id ="Image1"
src="Image1.jpg"
alt="Image 1"
runat="server"
style="width:500; height:226; border:5; text-align:center" />
</form>
</body>
</html>
以下程式碼範例示範如何將控制項包裹 HtmlImage 在段落標籤 align 內,並將屬性設定為 "center"。
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlImage Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HtmlImage Example</h3>
<p style="text-align:center">
<img id ="Image1"
src="Image1.jpg"
alt="Image 1"
runat="server"
style="width:500; height:226; border:5; text-align:center" />
</p>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlImage Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HtmlImage Example</h3>
<p style="text-align:center">
<img id ="Image1"
src="Image1.jpg"
alt="Image 1"
runat="server"
style="width:500; height:226; border:5; text-align:center" />
</p>
</form>
</body>
</html>
備註
使用此屬性來指定圖片相對於網頁其他元素的對齊方式。
下表表示可能的數值。
| 價值 | 說明 |
|---|---|
| left | 圖片對齊於網頁左側。 |
| 中心 | 圖片會對齊在網頁中央。 |
| 右 | 圖片對齊在網頁右側。 |
| top | 網頁中的其他元素則與圖片的頂端對齊。 |
| 中 | 網頁中的其他元素則對齊於圖片中間。 |
| 底部 | 網頁中的其他元素則與圖片的下緣對齊。 |
備註
中心值可能不一定能在所有瀏覽器上正常運作。 要將圖片置中,將控制項包裹 HtmlImage 在包含 align 屬性為 "center" ()<p align= "center"> 的段落標籤內。