Latest web development tutorials

HTML DOM Style verticalAlign property

Style Object Reference Style Objects

Definition and Usage

verticalAlign property sets or returns the element content in vertical alignment.

grammar

Setting verticalAlign properties:

Object.style.verticalAlign="value"

Back verticalAlign properties:

Object.style.verticalAlign

描述
length 通过指定的长度来提高或降低一个元素。可使用负值。
% 通过 "line-height" 属性的百分比来提高或降低一个元素。可使用负值。
baseline 默认。把元素的基线与父元素的基线对齐。
sub 垂直对齐文本的下标。
super 垂直对齐文本的上标。
top 把元素的顶端与行中最高元素的顶端对齐。
text-top 把元素的顶端与父元素字体的顶端对齐。
middle 把元素放置在父元素的中部。
bottom 把元素的底端与行中最低元素的底端对齐。
text-bottom 把元素的底端与父元素字体的底端对齐。
inherit 规定 verticalAlign 属性的值应该从父元素继承。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support verticalAlign property.

Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".


Examples

Examples

Changing the form of the Chinese vertical alignment:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
    document.getElementById("td1").style.verticalAlign="bottom";
}
</script>
</head>
<body>

<table border="1" height="100px">
  <tr>
    <td id="td1">一些实例文本</td>
  </tr>
</table>
<br>
<input type="button" onclick="displayResult()" value="对齐文本">

</body>
</html>

try it"


Style Object Reference Style Objects