©
本文档使用
php中文网手册 发布
vertical-align:baseline | sub | super | top | text-top | middle | bottom | text-bottom | <percentage> | <length>
默认值:baseline
适用于:内联级与 table-cell 元素
继承性:无
动画性:当值为 <length> 时
计算值:指定值
baseline:把当前盒的基线与父级盒的基线对齐。如果该盒没有基线,就将底部外边距的边界和父级的基线对齐
sub:把当前盒的基线降低到合适的位置作为父级盒的下标(该值不影响该元素文本的字体大小)
super:把当前盒的基线提升到合适的位置作为父级盒的上标(该值不影响该元素文本的字体大小)
text-top:把当前盒的top和父级的内容区的top对齐
text-bottom:把当前盒的bottom和父级的内容区的bottom对齐
middle:把当前盒的垂直中心和父级盒的基线加上父级的半x-height对齐
top:把当前盒的top与行盒的top对齐
bottom:把当前盒的bottom与行盒的bottom对齐
<percentage>:把当前盒提升(正值)或者降低(负值)这个距离,百分比相对line-height计算。当值为0%时等同于baseline。
<length>:把当前盒提升(正值)或者降低(负值)这个距离。当值为0时等同于baseline。(CSS2)
对应的脚本特性为verticalAlign。
| Values | IE | Firefox | Chrome | Safari | Opera | iOS Safari | Android Browser | Android Chrome |
|---|---|---|---|---|---|---|---|---|
| Basic Support | 6.0+ | 2.0+ | 4.0+ | 6.0+ | 15.0+ | 6.0+ | 2.1+ | 18.0+ |
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="utf-8" />
<title>vertical-align_CSS参考手册_web前端开发参考手册系列</title>
<meta name="author" content="Joy Du(飘零雾雨), dooyoe@gmail.com, www.doyoe.com" />
<style>
.test p{border:1px solid #000;font-size:16px;line-height:2;}
.test a{margin-left:5px;font-size:12px;}
.baseline a{vertical-align:baseline;}
.sub a{vertical-align:sub;}
.super a{vertical-align:super;}
.top a{vertical-align:top;}
.text-top a{vertical-align:text-top;}
.middle a{vertical-align:middle;}
.bottom a{vertical-align:bottom;}
.text-bottom a{vertical-align:text-bottom;}
.length a{vertical-align:10px;}
</style>
</head>
<body>
<ul class="test">
<li class="baseline">
<strong>与基线对齐</strong>
<p>参考内容<a href="?">基线对齐</a></p>
</li>
<li class="sub">
<strong>与参考内容的下标对齐</strong>
<p>参考内容<a href="?">下标对齐</a></p>
</li>
<li class="super">
<strong>与参考内容的上标对齐</strong>
<p>参考内容<a href="?">上标对齐</a></p>
</li>
<li class="top">
<strong>对象的内容与对象顶端对齐</strong>
<p>参考内容<a href="?">要对齐的内容</a></p>
</li>
<li class="text-top">
<strong>对象的文本与对象顶端对齐</strong>
<p>参考内容<a href="?">要对齐的内容</a></p>
</li>
<li class="middle">
<strong>对象的内容与对象中部对齐</strong>
<p>参考内容<a href="?">要对齐的内容</a></p>
</li>
<li class="bottom">
<strong>对象的内容与对象底端对齐</strong>
<p>参考内容<a href="?">要对齐的内容</a></p>
</li>
<li class="text-bottom">
<strong>对象的文本与对象顶端对齐</strong>
<p>参考内容<a href="?">要对齐的内容</a></p>
</li>
<li class="length">
<strong>与基线算起的偏移量</strong>
<p>参考内容<a href="?">偏移量对齐</a></p>
</li>
</ul>
</body>
</html>
点击 "运行实例" 按钮查看在线实例