සැකිල්ල:Table alignment
| මෙම සැකිල්ල පිටු බොහෝ ගණනක භාවිතා වන නිසා සිදුකරන වෙනස් කිරීම් බොහෝ ස්ථානවලට බලපානු ඇත. ඔබ සිදුකිරීමට අදහස් කරන වෙනස්කම් මෙම සැකිල්ලට අදාළ /sandbox හෝ /testcases උපපිටුවල, හෝ ඔබගේ පරිශීලක උපපිටුවේ පළමුව සිදුකොට පරීක්ෂාකර බලන්න. එම වෙනස්කම් සිදුකිරීමට ප්රථම අදාළ සාකච්ඡා පිටුවේ ඒ පිළිබඳව සංවාදයක් ගොඩනැගීමට කාරුණික වන්න.
Transclusion count updated automatically (ප්රලේඛනය වෙතට යොමුවන්න). |
| This template uses TemplateStyles: |
Purpose
[සංස්කරණය]To make it simpler to align the columns in tables with less wikicode.
Usage
[සංස්කරණය]Place {{Table alignment}} just before the table and then add some classes to the table.
| classname | Purpose |
|---|---|
defaultleft |
Align all table cells left by default |
defaultcenter |
Align all table cells center by default |
defaultright |
Align all table cells right by default |
colNleft |
Align the cells in column N left, where N is a number |
colNcenter |
Align the cells in column N center, where N is a number |
colNright |
Align the cells in column N right, where N is a number |
With the wikitable class the header cell content is always centered unless individually adjusted.
The col and default classes never affect the header cells (column, row, or anywhere) if the wikitable class is used. The col class overrides the default class.
If the wikitable class is not used, then col and default affect header cells.
Limitations
[සංස්කරණය]- Column numbers up to
col29are supported. A table can have more columns but they cannot be aligned with this method. - On tables using
rowspanorcolspan, using the classes may not work well on those rows because the alignment appears in wrong cells. Normal table code likestyle="text-align: left/center/right;"| cell contentcan be added to individual cells, both to get the wanted alignment and override unwanted alignment.
Example
[සංස්කරණය]{{Table alignment}}
{| class="wikitable defaultcenter col1left col4right"
!Item1
!Item2
!Item3
!Item4
|-
|AAAAAA
|100-200
|3-4
|53.43
|-
|BBB
|5-6
|7-8
|5563.35
|-
|CC
|9-10
|113-125
|322313.00
|}
| Item1 | Item2 | Item3 | Item4 |
|---|---|---|---|
| AAAAAA | 100-200 | 3-4 | 53.43 |
| BBB | 5-6 | 7-8 | 5563.35 |
| CC | 9-10 | 113-125 | 322313.00 |
Align a column of row headers
[සංස්කරණය]With the wikitable class the header cell content is always centered unless individually adjusted. So the template is no help with row header cells in this case.
Instead do a mass search-and-replace to add style=text-align:left to each row header cell. To do so be sure the table is in a separate article section, or in a sandbox. Click on the wikitext source editing link. Click on "Advanced" in the editing toolbar. Then click on the "search and replace" icon on the right. Fill in the "Search for" box with:
!
Fill in the "Replace with" box with:
! style=text-align:left|
Make sure all the option boxes are unchecked. Then click "Replace all".
Preview the page. Remove style=text-align:left| from the column headers. An easier way may be to cut out the top headers before the search-and-replace, and park them in Notepad or elsewhere.
Other individual cell adjustments may be needed. Publish the page.
See also
[සංස්කරණය]- {{shy}} – Can be used to help narrow columns by adding a soft hyphen to a word to allow it to wrap.
More template styles for tables:
- {{sticky header}} - Makes column headers stick to the top of the page while scrolling through table data.
- {{sticky table start}} - allows sticky rows and columns inside a scrollable area.
- {{sort under}} - moves the sorting arrows under the headers.
- {{row hover highlight}} - adds row hover highlighting, and option for white background.
- {{static row numbers}} - adds a column of row numbers to a table.