text-align-last
        
        
          
                Baseline
                
                  Widely available
                
                
              
        
        
        
          
                
              
                
              
                
              
        
        
      
      This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2022年9月.
CSS 属性 text-align-last 指定一行或者块中的最后一行在被强制换行之前的对齐规则。
语法
css
/* 关键字值 */
text-align-last: auto;
text-align-last: start;
text-align-last: end;
text-align-last: left;
text-align-last: right;
text-align-last: center;
text-align-last: justify;
/* 全局值 */
text-align-last: inherit;
text-align-last: initial;
text-align-last: revert;
text-align-last: revert-layer;
text-align-last: unset;
值
- auto
- 
受影响的行会根据 text-align的值来对齐,除非text-align的值是justify,在这种情况下,其效果等同于将text-align-last的值设置为start。
- start
- 
如果内容方向是左至右,则等于 left,反之则为right。
- end
- 
如果内容方向是左至右,则等于 right,反之则为left。
- left
- 
行内内容对齐到行框的左边缘。 
- right
- 
行内内容对齐到行框的右边缘。 
- center
- 
行内内容在行框中居中。 
- justify
- 
最后一行文字的开头与内容盒子的左侧对齐,末尾与右侧对齐。 
形式语法
text-align-last =
auto |
start |
end |
left |
right |
center |
justify |
match-parent
示例
>对齐最后一行
css
p {
  font-size: 1.4em;
  text-align: justify;
  text-align-last: center;
}
规范
| Specification | 
|---|
| CSS Text Module Level 3> # text-align-last-property> | 
浏览器兼容性
Loading…