Snippets/Horizontal lists: Difference between revisions
Appearance
< Snippets
Content deleted Content added
→Code: Update hlist (improved nowarp for ordered lists) |
Rev 9; update empty list item class |
||
| Line 18: | Line 18: | ||
/* Style for horizontal lists (separator following item). |
/* Style for horizontal lists (separator following item). |
||
@source mediawiki.org/wiki/Snippets/Horizontal_lists |
@source mediawiki.org/wiki/Snippets/Horizontal_lists |
||
@revision |
@revision 9 (2016-08-10) |
||
@author [[User:Edokter]] |
@author [[User:Edokter]] |
||
*/ |
*/ |
||
| Line 45: | Line 45: | ||
} |
} |
||
/* Hide empty list items */ |
/* Hide empty list items */ |
||
.hlist .mw-empty- |
.hlist .mw-empty-elt { |
||
display: none; |
display: none; |
||
} |
} |
||
Revision as of 18:46, 10 August 2016
| Language(s): | CSS |
|---|---|
| Compatible with: | MediaWiki 1.17+ (All skins) |
Description
Enables the use of horizontal lists, inline formatted, semantically valid HTML lists using the hlist class.
Use
Using horizontal lists only requires adding the hlist class to a container element that holds a HTML list. Lists may be in both HTML and wiki markup.
License
This code is released under the Creative Commons Attribution license (CC-BY) and the GNU GPL version 2 or later.
Code
Place the folowing code in MediaWiki:Common.css:
/* Style for horizontal lists (separator following item).
@source mediawiki.org/wiki/Snippets/Horizontal_lists
@revision 9 (2016-08-10)
@author [[User:Edokter]]
*/
.hlist dl,
.hlist ol,
.hlist ul {
margin: 0;
padding: 0;
}
/* Display list items inline */
.hlist dd,
.hlist dt,
.hlist li {
margin: 0;
display: inline;
}
/* Display nested lists inline */
.hlist.inline,
.hlist.inline dl,
.hlist.inline ol,
.hlist.inline ul,
.hlist dl dl, .hlist dl ol, .hlist dl ul,
.hlist ol dl, .hlist ol ol, .hlist ol ul,
.hlist ul dl, .hlist ul ol, .hlist ul ul {
display: inline;
}
/* Hide empty list items */
.hlist .mw-empty-elt {
display: none;
}
/* Generate interpuncts */
.hlist dt:after {
content: ": ";
}
.hlist dd:after,
.hlist li:after {
content: " · ";
font-weight: bold;
}
.hlist dd:last-child:after,
.hlist dt:last-child:after,
.hlist li:last-child:after {
content: none;
}
/* Add parentheses around nested lists */
.hlist dd dd:first-child:before, .hlist dd dt:first-child:before, .hlist dd li:first-child:before,
.hlist dt dd:first-child:before, .hlist dt dt:first-child:before, .hlist dt li:first-child:before,
.hlist li dd:first-child:before, .hlist li dt:first-child:before, .hlist li li:first-child:before {
content: " (";
font-weight: normal;
}
.hlist dd dd:last-child:after, .hlist dd dt:last-child:after, .hlist dd li:last-child:after,
.hlist dt dd:last-child:after, .hlist dt dt:last-child:after, .hlist dt li:last-child:after,
.hlist li dd:last-child:after, .hlist li dt:last-child:after, .hlist li li:last-child:after {
content: ")";
font-weight: normal;
}
/* Put ordinals in front of ordered list items */
.hlist ol {
counter-reset: listitem;
}
.hlist ol > li {
counter-increment: listitem;
}
.hlist ol > li:before {
content: " " counter(listitem) "\a0";
}
.hlist dd ol > li:first-child:before,
.hlist dt ol > li:first-child:before,
.hlist li ol > li:first-child:before {
content: " (" counter(listitem) "\a0";
}
