Fandom Developers Wiki
Advertisement
Fandom Developers Wiki

This cookbook is a collection of useful CSS snippets to be used however you want.

CSS tutorials

Background images

If you want to change the background image of your wiki using CSS, look no further. Generally, you can accomplish this using

body.mediawiki {
    background-image: url(<replace this with the url of the image you want the background to be>);
    background-color: <changes the color of the background, use a hex code or color name (i.e. "red")>;
    background-blend-mode: <combines two or more background layers together with different blend modes, use one of the names of the blend mode to change the resulting background appearance (examples: "color-dodge", "screen", "multiply", "hard-light", "difference", "luminosity")>
    background-attachment: <set to scroll to allow it to scroll with the page, or to fixed to keep its position static>;
    background-position: <set to either the directions from which to start the image (i.e. "top left", "left center", "right center", etc), percentages (x% y%), or position (xpos ypos). (Note: % and pos are mixable)>
    background-repeat: <the default setting is repeating the image both vertically and horizontally, setting to repeat-y will repeat the image only vertically, setting it to repeat-x will repeat it only horizontally, and setting it to no-repeat prevents it from repeating at all.>;
}

Some fine tuning may be required, but those are the basics.

Specific CSS

Fandom has several specific built-in classes.

  • .ns
    • Namespace specific class
    • This page's is .ns-0
/* Change text color in user namespace */
.ns-2 {
    color: black;
}
  • .theme-fandomdesktop-light and .theme-fandomdesktop-dark
    • Light and dark theme specific classes (Only available with the FandomDesktop skin)
/* Change link color on dark wikis but not light wikis */
.theme-fandomdesktop-dark a {
    color: white;
}
  • .page
    • Page specific class
    • This page's is .page-CSS_Cookbook
/* Add some styling on a certain page */
.page-CSS_Cookbook h2 {
    font-weight: bold;
}
  • .wiki
    • Wiki specific class
    • This wiki's is .wiki-dev
/* Add some styling only to dev wiki */
.wiki-dev .portable-infobox {
    padding: 1px;
}

Site enhancements

Blackout customization

Blackout.png

To customize the black out that appears when viewing an image on a lightbox, use this CSS snippet below:

.blackout {
    background: #84dcff;
    mix-blend-mode: overlay;
}

Change the color of the background #84dcff to the intended color and the blending type overlay to the intended mixing mode.

Block-style header

BlockHeader.png

This CSS snippet by JustLeafy, for UCX only, makes the page header looks like a block style with a solid background color. It indirectly returns the style of the Oasis-style header.

.fandom-community-header {
    background: var(--theme-sticky-nav-background-color);
    padding: 15px 20px 5px 20px;
    margin-bottom: -12px;
}

.page__main {
    border-radius: 0 0 3px 3px !important;
}

Condensed header dropdowns

CondensedHeaderDropdowns.png

This CSS snippet by JustLeafy, for UCX only, makes the style of the dropdowns of the page header look more condensed.

.fandom-community-header__local-navigation .wds-dropdown__content { padding: 0 !important }

.fandom-community-header__local-navigation .wds-dropdown__content .wds-list.wds-is-linked > li { padding: 0 6px !important; }

"No article text" background

ArticleNoTextBG.png

This site-wide only CSS snippet by Master Ceadeus 27 adds a background image to the missing article message:

#mw-content-text .noarticletext {
    background-image: url('<insert error image URL>');
    background-blend-mode: normal;
    background-size: cover;
}

Line-height customization

Customizing line-height is useful for Indic scripts such as Devanagari, Bengali, Kannada, Odiya, etc due to mātrās (such ि, ी, ु and ू), flowing off the lines in specific locations and making it look untidy. It is recommended that all wikis in the mentioned languages use this:

/* Community header */
.wds-community-header__sitename,
.fandom-community-header a,
/* Headings */
#content h2,
#content h3,
#content h4 {
    line-height: 1.5;
}

Link Customization

This CSS snippet was created by Cleverduck09 to customize what links wiki-wide look like on hover, once they have been visited, and when they haven't been visited or hovered on, input the following code:

a:link { /*What the link looks like when you haven't clicked/hovered on it*/
  color: CODE;
  background-color: CODE;
  text-decoration: CODE;
  text-shadow:CODE;
/*More CSS Attributes*/
}
a:visited { /*What the link looks like when you've visited it*/
  color: CODE;
  background-color: CODE;
  text-decoration: CODE;
  text-shadow:CODE;
/*More CSS Attributes*/
}
a:hover { /*What the link looks like when you're hovering on it*/
  color: CODE;
  background-color: CODE;
  text-decoration: CODE;
  text-shadow:CODE;
/*More CSS Attributes*/
}
a:active { /*What the link looks like when you click it*/
  color: CODE;
  background-color: CODE;
  text-decoration: CODE;
  text-shadow:CODE;
/*More CSS Attributes*/
}

Profile background

CustomProfileImage.png

If you want to insert a background image that spans across of profiles of users, you can use:

#userProfileApp {
    background-image: url("<insert URL to profile background image>");
}

Note: Add background-repeat: no-repeat; if you have added a wider image. They may not fit and will result in a repeating background.

Scrollbar customization

MinimalScrollbar.png

If you want to customize your wiki's scrollbar, you can use these CSS selectors to apply various properties to it:

/* Makes the scrollbar 8px wide */
::-webkit-scrollbar {
    width: 8px;
}

/* Makes the scrollbar track have a black background */
::-webkit-scrollbar-track {
    background: black;
}

/* Makes the scrollbar bar have a green background */
::-webkit-scrollbar-thumb {
    background: #228B22;
}

/* Makes the background for the scrollbar bar a darker shade of green when hovered */
::-webkit-scrollbar-thumb:hover {
    background: #222;
}

Note: Scrollbar customization is only supported in WebKit based browsers, like Chrome, Safari, and Opera.

Username highlighting

HighlightUsername.png

This CSS snippet highlights links to an administrator's userpage, Message Wall, contributions and blog listing:

a[href$=":Admin's_Username"],
a[href$="/Admin's_Username"] {
    /* changes the color of the username */
    color: #006600 !important;
    /* makes the username bold */
    font-weight: bold !important;
    /* changes the font of the username */
    font-family: Arial !important;
    /* other CSS goes here */
}

Change Admin's_Username to the username of the administrator you intend to highlight, #006600 to the intended color of highlighting and Arial to the intended font for the highlight. You can also remove certain sections if you don't need them in the highlight.

Note: For usernames with spaces in them, message walls encode the spaces with %20, while the MediaWiki part encodes the spaces with underscores. So in order to highlight both, both versions need to be included in the CSS rule. For example:

a[href$=":Admin's_Username"],
a[href$="/Admin's_Username"],
a[href$=":Admin's%20Username"],
a[href$="/Admin's%20Username"]  {
    /* ... */
}

In case there are other special characters in the username (such as & or ' ), those need appropriate encoding as well.

Change outline style

DifferentOutlineStyle.png

This minor CSS plug-in customizes the style of the outline. The outline means the blue border that appears when tabbing (using Tab to navigate a page). It is a style that is not to be confused with border. An outline is a line that is drawn around elements (outside the borders) to make the element "stand out". Here is a list of the outline properties and their definitions.

  • outline-color: Sets the color of the outline. (e.g. red outline).
  • outline-style: Sets the style of the outline. (e.g. dotted, dashed, solid etc.)
  • outline-width: Sets the width of the outline. (e.g. 3-pixel wide outline)
  • outline-offset: Sets the amount of space between an outline and the edge or border of an element. (e.g. Outline with an offset that is 3 pixels large)
/* Customize the outline color, width, style and offset (note that this is an example and you can change the properties to your preferences) */
a:focus {
    outline-color: green;
    outline-offset: 1px;
    outline-style: solid;
    outline-width: 2px;
}

Round corners on Special:Community

This snippet by Louky rounds corners of Community Page modules:

.community-page-card-module-header, .community-page-card-module {
    border-radius: 40px 40px / 40px 40px;
}

Pixelized images

This snippet by Rail makes sure that low resolution pixelart images are being displayed without antialiasing applied by Fandom's image processing service.

.mw-parser-output img {
    -ms-interpolation-mode: nearest-neighbor;
    image-rendering: -moz-crisp-edges;
    image-rendering: -o-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

Reduced motion

This CSS snipet will make the duration of all CSS animations and transitions in such a short time that they are not noticeable anymore, while keeping it functional in case there's scripts that depends on animations and/or transitions to work. This can be useful for people who don't like animations, have motion-triggered vestibular spectrum disorders or want to improve page performance. The code will take effect only if the user has the prefers-reduced-motion preference on their system set to true. Snippet from web.dev.

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-delay: -1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    background-attachment: initial !important;
    scroll-behavior: auto !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }
}

You can also remove the media query to apply it to the wiki no matter the user's preference.

Accessible navigation buttons

Allows links in the navigation bars to be keyboard-navigable (it's highly recommended to implement along with JumpToContent since it can drastically increase the amount of links keyboard users will have to navigate in each page before getting to its contents).

.wds-dropdown:not(.wds-is-touch-device):not(.wds-is-not-hoverable):is(:hover, :focus, :focus-within) .wds-dropdown__content,
.fandom-community-header__local-navigation .wds-dropdown__content .wds-list.wds-is-linked .wds-dropdown-level-nested:not(.wds-is-touch-device):is(:hover, :focus, :focus-within) > .wds-dropdown-level-nested__content {
  display: block;
}

Edit sections

Hidden edit sections

HiddenEditSectionUCP screenshot.png

This UCP-only CSS snippet by Александр III hides all edit links next to section headers.

.mw-editsection {
    display: none;
}

Change icon for edit sections

This UCP-only CSS snippet by Laclale and KockaAdmiralac changes icon for all edit links next to section headers. You can change the URL that links to image.

.section-edit-pencil-icon, .mw-editsection .wds-icon {
    background: url('https://vignette.wikia.nocookie.net/ocraviutl/images/1/13/EditVester.png/revision/latest?cb=20180302160206&path-prefix=ja') no-repeat;
}
.section-edit-pencil-icon use, .mw-editsection .wds-icon use {
    opacity: 0;
}

User customizations

Mobile Dark Mode

This CSS snippet by Headquarter8302 makes a very simple mobile dark mode, this snippet may become irrelevant in the future because Fandommobile promises a built in dark mode.

Note that this snippet would only become relevant if placed in your Fandommobile.css page.

body {
    background: black;
    color: white;
}

Cursor customization

CustomCursor.png

Personal CSS only: sitewide use violates customization policy.

If you want to change the icon displayed as your cursor, you can use:

/* This cursor icon will be displayed normally */
body {
    cursor: url("<insert URL to cursor icon>");
}

/* This cursor icon will be displayed when hovering or clicking on links */
a:hover, a:active {
    cursor: url("<insert URL to cursor icon>");
}

Detect Username Template

DetectUsername.png

This CSS snippet by TheGoldenPatrik1 places a border around the {{USERNAME}} template to prevent users from being fooled by it:

.insertusername,
.inputusername,
.InsertUsername,
.InputUsername {
    border: 1px solid;
    padding: 0.5px;
}

Force default cursor

ForceDefaultCursor.png

This personal only CSS snippet forces all cursors to become default. This means that custom wiki cursors will be restored back to default. It also replaces the hand cursor when hovering over links with the default cursor.

body,
* {
    cursor: default !important;
}

a:hover {
    cursor: pointer !important;
}

Hide START A NEW WIKI button

This personal only CSS snippet by Headquarter8302 hides the

START A NEW WIKI

button next to the notifications dropdown.

div.wds-global-navigation__start-a-wiki, .global-navigation__link.start-a-wiki {
    display: none;
}

Hide main page categories

NoCat.png

This personal-only CSS snippet by JustLeafy and KockaAdmiralac prevents the bottom category bar to appear on the main page:

.mainpage .article-categories, .mainpage .page-footer__categories {
    display: none;
}

Hide main page title

This personal-only CSS snippet by DiegoFire Network and KockaAdmiralac removes the title of a wiki's main page.

.mainpage .WikiaPage .page-header__title,
.mainpage .WikiaPage .page-header__separator,
.mainpage #firstHeading {
    display: none;
}

Hide Trending Fandom Articles

AnonSnippet2.png

This personal only CSS snippet by Anonminati hides the trending Fandom articles.

#WikiaAdInContentPlaceHolder.rail-sticky-module {
    display: none;
}

Minified PPH

MinifiedPPH.png

This personal-only CSS snippet by KurwaAntics minifies Fandom's new article header by removing the category list and language dropdown button on the top of the header and reducing the article's title's font size:

.page-header__categories,
.page-header__languages {
    display: none;
}
.page-header__title {
    font-size: 34px;
}

Previous WDS Button design

OldWDSButtons.png

This minor CSS plugin by JustLeafy makes the buttons look like the previous style before they had rounded corners and a larger font size.

.wds-button {
    padding: 7px 12px;
    font-size: 10px;
    border-radius: 0 !important;
}

Selection customization

CustomSelection.png

This CSS snippet by JustLeafy makes the selection background color semi-transparent.

::selection {
  background: rgba(120,120,120,0.5);
}

Smooth Page Load

Example of the Smooth Page Load This personal only CSS code by Cleverduck09 creates a short fade-in animation on wiki pages.

@keyframes pageload {
    from { opacity: 0; }
    to { opacity: 100; }
}
body,
.Message__content,
.wds-dropdown,
.wds-tabs__tab,
.wds-dropdown__toggle,
.client-js {
    animation-name: pageload;
    animation-duration: 0.4s;
    animation-iteration-count: 1;
    animation-delay: 0s;
}

Static TFA rail module

StaticTFA.png

This personal only CSS snippet by JustLeafy makes the "Trending Fandom Articles" module static when scrolled past:

#WikiaAdInContentPlaceHolder.rail-sticky-module {
    position: static;
}

Change diff highlights

This CSS snippet by RyaNayR adds a red outline-border to diff-change highlight color-scheme. This would presumably greatly increase visibility of small, one-character changes, while also remaining palatable to the eyes on larger diffs, when anyone on your wiki is reviewing edit-differences.

.diffchange {
    border: 1px solid #f00;
}

Remove Fan Feed

Remove Fan Feed.png

This is a simple CSS snippet that removes the Fan Feed which is located at the bottom of the main page, article pages and file pages.

#mixed-content-footer {
    display: none;
}

Caret Color

CaretColor.png

Caret Color is a simple stylesheet that gives the caret (or text indicator cursor) a different color. Currently, the caret can only be colored with the caret-color, but the width and other properties are not customizable yet because these properties don't exist yet. This minor CSS plug-in will affect the caret in all textareas. Note that the caret color here is red, but it can definitely be changed to a different color.

textarea {
    caret-color: red;
}

Hide Read Feeds/Announcements Notifications

This CSS snippet added by Andrewds1021 and KockaAdmiralac hides read notifications in the Feeds/Announcements notification drop-down (the bell icon in the global navigation header). It also re-works how the horizontal rules are added between notifications such that the last unread notification is not followed by an extraneous horizontal rule. This is for personal use only.

/* hiding read notifications */
#notificationContainer .wds-notification-card:not(.wds-is-unread), .notifications li:not([class*="isUnread"]) {
    display: none;
}

/* re-working horizontal rules */
#notificationContainer.wds-has-lines-between > li {
    border-bottom: 0;
    border-top: 1px solid #bed1cf;
}
 
#notificationContainer.wds-has-lines-between > li:first-child {
    border-top: 0;
}

Large thumbnails in Dynamic Categories on UCP

This CSS snippet by HumansCanWinElves and partially based on Fandom's own stylesheet, turns all the entries in category pages to look like the "Trending pages" at the top - four columns with large thumbnails. This works for users who use the default "Dynamic Categories" view.

The images look somewhat blurry, since they are low-resolution thumbnails enlarged by CSS.

Entries without an image will display the Fandom logo, and this can be replaced by changing the URL in the middle of the code. In this case, usually you will also want to change the "80%" size definition to "100%".

.ns-14 #content .category-page__members.category-page__members {
    column-count: 1;
}

.ns-14 #content .category-page__members-for-char {
    display: -ms-inline-flexbox;
    display: grid;
    -ms-flex-wrap: wrap;
    grid-gap: 20px;
    grid-template-columns: repeat(4,1fr);
    margin-left: 0;
}

.ns-14 #content .category-page__member {
    flex-direction: column;
}

.ns-14 #content .category-page__member-left {
    width: 160px;
    height: 120px;
    background: url(https://static.wikia.nocookie.net/740bff54-a89f-4c0a-97a1-a97c6b1a77a7) no-repeat center center/auto 80%;
    border: 1px solid;
    justify-content: flex-start;    
}

.ns-14 #content .category-page__member-thumbnail {
    width: 160px;
    height: 120px;
    border: none;
}

.ns-14 #content .category-page__member-link {
    text-align: center;
}

Mobile Light/Dark Theme

The following snippets are for personal use with FandomMobile and should be placed at the top of fandommobile.css on whichever wiki the user wishes to change the theme. Only one of the snippets should be used on a given wiki. For non-English wikis, prefix the URL with the proper language code.

Fandom Light - default for most fandom.com wikis

@import "/load.php?only=styles&modules=ext.fandom.DesignSystem.GlobalNavigation.brand.light.css|ext.fandom.DesignSystem.brand.light.css|skin.fandommobile.fandom.light.css";

Fandom Dark

@import "/load.php?only=styles&modules=ext.fandom.DesignSystem.GlobalNavigation.brand.dark.css|ext.fandom.DesignSystem.brand.dark.css|skin.fandommobile.fandom.dark.css";

Wikia Light - default for most wikia.org wikis

@import "/load.php?only=styles&modules=ext.fandom.DesignSystem.GlobalNavigation.brand.wikiaorg-light.css|ext.fandom.DesignSystem.brand.wikiaorg-light.css|skin.fandommobile.wikiaorg.light.css";

Wikia Dark

@import "/load.php?only=styles&modules=ext.fandom.DesignSystem.GlobalNavigation.brand.wikiaorg-dark.css|ext.fandom.DesignSystem.brand.wikiaorg-dark.css|skin.fandommobile.wikiaorg.dark.css";

Non-English Example - use dark theme on a Spanish fandom.com wiki

@import "/es/load.php?only=styles&modules=ext.fandom.DesignSystem.GlobalNavigation.brand.dark.css|ext.fandom.DesignSystem.brand.dark.css|skin.fandommobile.fandom.dark.css";

note: If you like the primarily yellow theme used for anonymous users, use ext.fandom.DesignSystem.GlobalNavigation.brand.default.css.

Hide StickyNav

This short, personal only, FandomDesktop snippet by BlindCartographer stops the stickied top navigation from ever appearing.

.fandom-sticky-header {
	display: none !important
}
Text above can be found here (edit)
Advertisement