HTML <input> 标签的 align 属性

HTML <input> 标签

实例

下面的表单拥有两个输入字段以及一个图像形式的提交按钮:

  1. <form action="form_action.asp" method="get">
  2. <p>First name: <input type="text" name="fname" /></p>
  3. <p>Last name: <input type="text" name="lname" /></p>
  4. <input type="image" src="submit.jpg" alt="Submit" align="right" />
  5. <p>This is some text This is some text This is some text.</p>
  6. </form>

定义和用法

align 属性只能与 <input type="image"> 配合使用。它规定图像输入相对于周围其他元素的对齐方式。

浏览器支持

只有 “left” 和 “right” 值得到所有浏览器的支持。

兼容性注释

在 HTML 4.01 中,不赞成使用 input 元素的 align 属性。在 XHTML 1.0 Strict DTD 中不支持该属性。

请使用 CSS 代替。

CSS 语法:<input type="image" style="float:right" />

CSS 实例: 对齐 input 图像

  1. <form action="/example/html/form_action.asp" method="get">
  2. <p>First name: <input type="text" name="fname" /></p>
  3. <p>Last name: <input type="text" name="lname" /></p>
  4. <input type="image" src="/i/eg_submit.jpg" alt="Submit" style="float:right" />
  5. <p>This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text .</p>
  6. </form>
  7. <p>请在这幅图像上单击,输入会发送到服务器上名为 "form_action.asp" 的页面。</p>
  8. <p class="note"><span>注释:</span>如果 type 属性设置为 image,当用户单击图像时,浏览器将以像素为单位,将鼠标相对于图像边界的偏移量发送到服务器,其中包括从图像左边界开始的水平偏移量,以及从图像上边界开始的垂直偏移量。</p>
  9. <p>在 HTML 4.01 中,不赞成使用 input 元素的 align 属性。在 XHTML 1.0 Strict DTD 中不支持该属性。请使用 CSS 代替。</p>

在我们的 CSS 教程中,您可以找到更多有关 float 属性 的细节。

语法

  1. <input accept="value">

属性值

描述
left 左对齐图像(默认)。
right 右对齐对象。
top 上对齐图像。
middle 居中对齐图像。
bottom 下对齐图像。