?
This document uses PHP Chinese website manual Release
text-indent:[ <length> | <percentage> ] &&hanging? &&each-line?
默認值:0
適用于:塊容器
繼承性:有
動畫性:當使用值為非關鍵字時
計算值:指定值
<length>:用長度值指定文本的縮進。可以為負值。
<percentage>:用百分比指定文本的縮進。可以為負值。
each-line:定義縮進作用在塊容器的第一行或者內部的每個強制換行的首行,軟換行不受影響。(CSS3)
hanging:反向所有被縮進作用的行。(CSS3)
內聯(lián)對象要使用該屬性必須先使該對象表現(xiàn)為塊級或內聯(lián)塊級。
hanging和each-line關鍵字緊隨在縮進數(shù)值之后
示例代碼:
div{text-indent:2em each-line;}
以上代碼將使得div內部的第一行及每個強制換行的首行都擁有2em的縮進
對應的腳本特性為textIndent。
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+ |
hanging | each-line | 6.0-11.0 | 2.0-37.0 | 4.0-41.0 | 6.0-8.0 | 15.0-27.0 | 6.0-8.3 | 2.1-4.4.4 | 18.0-40.0 |
<!DOCTYPE html> <html lang="zh-cmn-Hans"> <head> <meta charset="utf-8" /> <title>text-indent_CSS參考手冊_web前端開發(fā)參考手冊系列</title> <meta name="author" content="Joy Du(飄零霧雨), dooyoe@gmail.com, www.doyoe.com" /> <style> .test p{border:1px solid #000;} .inline span{text-indent:30px;} .inline-block span{display:inline-block;text-indent:30px;} .block span{display:block;text-indent:30px;} .other{text-indent:30px;} .other ins{display:inline-block;background:#eee;} </style> </head> <body> <ul class="test"> <li class="inline"> <strong>內聯(lián)元素span</strong> <p><span>看看我的左邊有沒有30px的縮進 span{text-indent:30px;}</span></p> </li> <li class="inline-block"> <strong>被設置為內聯(lián)塊級元素的span</strong> <p><span>看看我的左邊有沒有30px的縮進 span{display:inline-block;text-indent:30px;}</span></p> </li> <li class="block"> <strong>被設置為塊級元素的span</strong> <p><span>看看我的左邊有沒有30px的縮進 span{display:block;text-indent:30px;}</span></p> </li> <li class="other"> <strong>包含有內聯(lián)塊的塊級元素</strong> <p><span>看看我的左邊有沒有30px的縮進</span><ins>我是一個被插入的內聯(lián)塊元素</ins>.other{text-indent:30px;}</p> </li> </ul> </body> </html>
點擊 "運行實例" 按鈕查看在線實例