Category:Collapsible box templates

From Cannabis
Jump to navigation Jump to search

Expand/collapse (or show/hide) table format:

Header text  
Text, etc.
More text.
{| class="wikitable mw-collapsible mw-collapsed"  border=1 cellpadding=4 rules=all
! style=text-align:left; | Header text  
| Text, etc.
| More text.


Don't forget to add the above wikitext for a nonbreaking space to the right of the header text. So that right-side show/hide toggles are not directly adjacent to header text. An easier method is to put a plain space before the period at the end of the header text. This helps with a problem in mobile view. See: User:Timeshifter/Sandbox22.

! style=text-align:left; | Header text

This is needed. Otherwise the header text can go offscreen to the right for wide tables in narrow screens.

border=1 cellpadding=4 rules=all 

Not required. But helpful when tables are copied and pasted into email, web pages, etc.. This keeps cell borders and padding for all cells in the table. Padding is important since tables may have a different background color adjacent to it.

You can override colors with this inline styling in the header wikitext:

  • !style="background-color:xxxxx; color:yyyyy;" |

Substitute color names or values for xxxxx and yyyyy. You can choose colors from these lists:

When using inline CSS to set header background color use this

  • style="background-color:xxxxx;"

instead of

  • style="background:xxxxx;"

Otherwise sorting in sortable tables may be broken. See Wikipedia:Help:Sorting, and bug 31755.

For more info see:

style="background-color:white; color:black;"

This is needed for some templates that expand into the gray space on the right side when the screen is narrow. For example; this template:

Plain text color must contrast with background color, so don't forget color:black;