version=pmwiki-2.2.16 ordered=1 urlencoded=1 agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1064 Safari/532.5 author=Linfeng charset=UTF-8 csum=translation ctime=1274507235 host=219.79.25.44 name=PmWikiZhTw.Tables rev=1 targets=PmWiki.TableDirectives,Cookbook.RowspanInSimpleTables,Cookbook.FormattingTables,PmWiki.WikiStyles text=(:Audience: authors (basic) :)%0a(:Summary:Simple tables with double pipe markup, one row per line:)%0a(:title 表格格式:)%0a!! 基本表格%0a%0aPmWiki 有兩種類型的表格; 在此頁面描述用於創建 ''簡單的'' 表格與大量的單元格, 而 [[PmWiki/table directive(s)]] 適用於規模較大的表格. 對於更多的表格格式參照 [[Cookbook:Rowspan in simple tables]] 及 [[Cookbook:Formatting tables]]。%0a%0a創建表格可使用的雙管字符: @@||@@ 。表格行與行的格式與起始時一致。表格邊框是用來分隔單元格。下面的例子是添加了一個邊框作說明(默認是沒有邊框)。%0a%0a第一行標記中包含命令的格式。只有 @@||@@ 在起始%0a%0a(:markup caption='基本表格' class=horiz:)%0a|| border=1%0a|| cell 1 || cell 2 || cell 3 ||%0a|| cell 1 || cell 2 ||%0a(:markupend:)%0a%0a表頭可以作為表格第一行的字符,請注意,這些都是 ''表頭'' ,不是 ''標題'' ,所以它不會延伸到 !!, !!!, 等等%0a%0a(:markup caption='表頭' class=horiz:)%0a|| border=1%0a||! cell 1 ||! cell 2 ||! cell 3 ||%0a|| cell 1 || cell 2 || cell 3 ||%0a(:markupend:)%0a%0a一個表格可以有一個標題, 以 [@||!表格 標題!||@]作表示,標題必須出現在表格行之前%0a%0a(:markup caption='表格 標題' class=horiz:)%0a|| border=1%0a||! 表格 標題 !||%0a||! cell 1 ||! cell 2 ||! cell 3 ||%0a|| cell 1 || cell 2 || cell 3 ||%0a(:markupend:)%0a%0a%0a!! 單元格格式%0a%0a單元格的內容格式可以是左對齊,居中,右對齊%0a* 左對齊, 將單元格內容緊貼開始的 @@||@@。%0a* 居中, 將單元格內容後面添加一個空格。%0a* 右對齊, 將空格置於單元格內容之前及緊貼 @@||@@。%0a%0a(:markup caption='單元格排列':)%0a|| border=1 width=100%25%0a||!cell 1 ||! cell 2 ||! cell 3||%0a||左對齊 || 居中 || 右對齊||%0a(:markupend:)%0a%0a(:markup caption='默認單元格排列':)%0a|| border=1 width=100%25%0a||!cell default||!cell left ||%0a||default-aligned||left-aligned ||%0a(:markupend:)%0a%0a請注意,標題和單元格具有不同的默認對齊%0a%0a要設定合併單元格,可設置一個空單元格。%0a(目前沒有標記的跨越行.)%0a%0a(:markup caption='Column spanning':)%0a|| border=1 width=100%25%0a|| |||| right column ||%0a|| || middle column ||||%0a|| left column ||||||%0a|| left column || middle column || right column ||%0a(:markupend:)%0a%0a!! 表格屬性%0a%0a任何開頭 [@||@] 並沒有結尾 [@||@],可設定 ''表格屬性''。這些屬性可以控制表格的大小和位置,邊框,背景顏色和單元格間距。 (其實這只是標準的HTML屬性%3ctable>設置)%0a%0a使用 [@width=@] 屬性來設置表的寬度, 使用一個百分比值,確定的數值,或 '''*'''.%0a%0a(:markup caption='Table width':)%0a|| border=1 width=100%25 %0a|| cell 1 || cell 2 || cell 3 ||%0a|| c1 || cellcellcellcell2 || cell 3 ||%0a(:markupend:)%0a%0a[@border=@] 屬性設置框線間距的大小%0a%0a(:markup caption='厚邊框表格' class=horiz:)%0a|| border=10 width=70%25%0a||!cell 1 ||! cell 2 ||! cell 3||%0a||左對齊 || 居中 || 右對齊||%0a(:markupend:)%0a%0a(:markup caption='無邊框表格' class=horiz:)%0a|| border=0 width=70%25%0a||!cell 1 ||! cell 2 ||! cell 3||%0a||左對齊 || 居中 || 右對齊||%0a(:markupend:)%0a%0a使用 [@align=center@], [@align=left@], 或 [@align=right@] 設置中間,靠左,或靠右表格。注意使用 [@align=left@] 或 [@align=right@] 創建 ''浮動表格'' 時,文字會環繞表格。%0a%0a(:markup caption='表格位置: 中間':)%0a|| border=1 align=center width=50%25%0a||!cell 1 ||! cell 2 ||! cell 3||%0a||左對齊 || 居中 || 右對齊||%0a注意本文字,使用 "align=center" 格式%0a(:markupend:)%0a%0a(:markup caption='表格位置: 靠左':)%0a|| border=1 align=left width=50%25%0a||!cell 1 ||! cell 2 ||! cell 3||%0a||左對齊 || 居中 || 右對齊||%0a注意本文字,使用 "align=left" 格式%0a(:markupend:)%0a%0a(:markup caption='表格位置: 靠右':)%0a|| border=1 align=right width=50%25%0a||!cell 1 ||! cell 2 ||! cell 3||%0a||左對齊 || 居中 || 右對齊||%0a注意本文字,使用 "align=right" 格式%0a(:markupend:)%0a%0a注意: 要讓一個表左對齊 (而不是"浮動左") CSS 語法,%0a->[@||style="margin-left:0px;"@]%0a%0a[@bgcolor=@]屬性設置表格的底色。這種類型的表格還可以指定單個欄或單元格(參見 Cookbook:FormattingTables).%0a%0a(:markup class=horiz:)%0a|| border=1 align=center bgcolor=yellow width=70%25%0a||!cell 1 ||! cell 2 ||! cell 3||%0a||左對齊 || 居中 || 右對齊||%0a(:markupend:)%0a%0a>>faq%3c%3c [[#faq]]%0aQ: How do I create a basic table? %0aA: Tables are created via use of the double pipe character: @@||@@. Lines beginning with this markup denote rows in a table; within such lines the double-pipe is used to delimit cells. In the examples below a border is added for illustration (the default is no border).%0a%0a(:markup caption='Basic table' class=horiz:)%0a|| border=1 rules=rows frame=hsides%0a|| cell 1 || cell 2 || cell 3 ||%0a|| cell 1 || cell 2 || cell 3 ||%0a(:markupend:)%0a%0aQ: How do I create cell headers?%0aA: Header cells can be created by placing ! as the first character of a cell. Note that these are ''table headers'', not ''headings'', so it doesn't extend to !!, !!!, etc.%0a%0a(:markup caption='Table headers' class=horiz:)%0a|| border=1 rules=cols frame=vsides%0a||! cell 1 ||! cell 2 ||! cell 3 ||%0a|| cell 1 || cell 2 || cell 3 ||%0a(:markupend:)%0a%0aQ: How do I obtain a table with thin lines and more distance to the content?%0aA: "Thin lines" is tricky and browser dependent, but the following works for Firefox and IE (Nov. 2009):%0a%0a(:markup caption='Thin lines and cell padding' class=horiz:)%0a||border="1" bordercolordark="black" bordercolorlight="black" style="border-collapse:collapse" cellpadding="5" width=66%25%0a||!Header || !Header|| '''Header'''||%0a||cells || with || padding||%0a|| || || ||%0a(:markupend:)%0a%0aQ: How do I create an advanced table? %0aA: See [[PmWiki.TableDirectives | table directives]]%0a%0aQ: My tables are by default centered. When I try to use '||align=left' they don't align left as expected. %0aA: Use ||style="margin-left:0px;" instead. %0a%0aQ: How can I specify the width of columns?%0aA: You can define the widths via custom styles, see Cookbook:FormattingTables and $TableCellAttrFmt. Add in config.php :%0a[@$TableCellAttrFmt = 'class=col\$TableCellCount';@]%0a-> And add in pub/css/local.css : %0a[@%0atable.column td.col1 { width: 120px; }%0atable.column td.col3 { width: 40px; }%0a@]%0a%0aQ: How can I display a double pipe "||" in cell text using basic table markup?%0aA: Escape it with [@[=||=]@] to display || unchanged.%0a%0aQ: How to I apply styles to the elements of the table, like an ID to the table row, or a class/style to the TD?%0aA: See [[PmWiki/WikiStyles#WikiStyleApply | $WikiStyleApply]]. time=1274507235 title=表格格式