Help:CSS: Difference between revisions

From the Super Mario Wiki, the Mario encyclopedia
Jump to navigationJump to search
(even more properties.)
Line 88: Line 88:
*padding, padding-top, padding-bottom, padding-left, padding-right – Padding sets space in between the border of an element and its text.
*padding, padding-top, padding-bottom, padding-left, padding-right – Padding sets space in between the border of an element and its text.
**Pixels only. Here decimals are OK.
**Pixels only. Here decimals are OK.
*list-style-image
*list-style-image &ndash; This is special for the <tt>ul</tt> (unordered [bullet] list) selector, and can change the 5X5 pixel bullet image. More on this below.
**This is special for the <tt>ul</tt> (unordered [bullet] list) selector, and can change the 5X5 pixel bullet image. More on this below.
**url(''url'');
*list-style-type &ndash; This is special for the <tt>li</tt> (ordered list) selector, and can change the numbers to:
**decimal (default), lower-roman (i, ii, v), upper-roman (I, II, V), lower-alpha (a, b, c), upper-alpha (A, B, C)
 
*-moz-border-radius, -moz-border-radius-topleft, -moz-border-radius-bottomleft, -moz-border-radius-topright, -moz-border-radius-bottomright &ndash; this Firefox-only property cuts off corner[s] at the edge of a table by a specified amount &ndash; that is, making the edge rounded.
*-moz-border-radius, -moz-border-radius-topleft, -moz-border-radius-bottomleft, -moz-border-radius-topright, -moz-border-radius-bottomright &ndash; this Firefox-only property cuts off corner[s] at the edge of a table by a specified amount &ndash; that is, making the edge rounded.
**Takes pixels or ''em''s. One em is &ndash; wide (yes, the ''em dash'' is the long dash standardly used on this wiki).
**Takes pixels or ''em''s. One em is &ndash; wide (yes, the ''em dash'' is the long dash standardly used on this wiki).
Line 95: Line 98:
<sup>1</sup>There are properties such as ''border-left-width'', ''border-bottom-style'', ''border-right-color'' as well.
<sup>1</sup>There are properties such as ''border-left-width'', ''border-bottom-style'', ''border-right-color'' as well.
==List of Selectors==
==List of Selectors==
Keep in mind that a) some selectors will only take certain values, b) many selectors will have specific names, unique to wikis, and c) Wayoshi's example provided eight common selectors. Those selectors takes all font, color, and text-decoration values.
Keep in mind that a) some selectors will only take certain values (experiment!), b) many selectors will have specific names, unique to wikis, and c) Wayoshi's example provided eight common selectors. Those selectors all take font, color, and text-decoration values.
 
*p &ndash; common paragraph. Used in raw websites from HTML, and used as a compound on wikis.
*<nowiki>#</nowiki>content, #content table, #p-cactions ul li a &ndash; grouped together for a reason, see below.
*.usermessage &ndash; the message table that appears when your talk page has been revised.
*<nowiki>#</nowiki>p-logo a &ndash; the logo. Code for changing the logo is found below. (background)
*textarea &ndash; Edit box. Code that utilizes the Mario bg we use now can be found at [[MediaWiki:Monobook.css]].
*pre &ndash; the table used inbetween <nowiki><pre></nowiki> tags.
*ul &ndash; unordered (bullet) list
*li &ndash; ordered (number) list
*h1, h2, h3, h4, h5, h6 &ndash; in order: Title of Page, Section Header, Sub-Section Header, &ndash; matching to as number of = used in wiksyntax.
*<nowiki>#</nowiki>catlinks &ndash; the table that contains categories.
*<nowiki>#</nowiki>siteNotice &ndash; as says.
*select &ndash; dropdown menus.
*input &ndash; input boxes, like Summary.
*input.searchButton &ndash; the buttons such as "Go" and "Save page".
*<nowiki>#</nowiki>searchinput &ndash; specific selector for the search box.

Revision as of 21:17, November 25, 2006

This article is under construction. Therefore, please excuse its informal appearance while it is being worked on. We hope to have it completed by Sunday.

  1. Be familiar with hex colors before reading this.
  2. Many of the codes shown on this page can be used as Template:Link styles.

CSS (officially known as Cascading Style Sheets) sets how a page looks. On a special sub-page on your user page, you can override the Monobook skin to create your own personal look for the wiki.

Background

CSS has three parts: A selector is the variable (officially the HTML element you're editing). A property is the attribute of the element you want to change. Each property has a value, which is set by default and the true item you are changing.
Consider the following line:

body {
  color: #00FF00;
 }

The selector/element that was edited was body – all the general text on a page. The property/attribute was color – text color. The value was #00FF00 – making all text a green color.

Note the syntax for CSS. The selector is defined first, then an opening brace ({) "opens" the element for editing. Then the property appears, with a colon (:) after it, then the value (hex colors must have the # sign). Each time a value is set, a semicolon (;) is required at the end (except for the last line). Multiple lines of properties and redefined variables can occur within the element, as long as they are closed by a closing brace (}).

selector {
  property1: value;
  property2: value;
  property3: value;
 }

Keep in mind that while the wiki has selectors that are common to all sites, some of them are also unique to wikis only

The following is a list elements, attributes, and values that are common to be changed, thus likely vital to your CSS page.

Example

Wayoshi (talk) has been kind enough to allow us to use his CSS page for an example first, using all three parts of CSS.

Let's take a look at the "body" and "a" selectors:

body { font-family:Arial; font-size:10px;}
a { color: #080; text-decoration: none; }
a:visited { color: #050; }
a:active { color: #111; }
#p-personal a.new { color: #b00; }
#p-personal a.new:visited { color:#800; }
#bodyContent a.external { color: #0a0; }
#bodyContent a.extiw:active { color: #020; }
  • The body selector covers the basic text on any page (such as what you'd see as content on a wiki page).
  • The a selector is the basic link that hasn't been clicked on recently.
  • a:active is when you are in the midst of clicking the link.
  • a:visited is the link that has been clicked recently. Often, it is simply the same color, but darker than a.
  • #p-personal a.new is the wiki-unique link-that-hasn't-been-created (red) link.
  • #p-personal a.new:visited is when you try to create a page, but don't right away, so it has a different color elsewhere until it's created, when it becomes a.
  • #bodyContent a.external is the external link.
  • #bodyContent a.extiw:active is when an external link is being clicked on.
  • Result: Normal text is changed from 12px Verdana to 10px Arial. The normal and external links are now green. When clicking on a link, the color is a dark shade of green or gray. The uncreated page links are a darker shade of red.
  • In the first example, different parts were on different lines. In fact, all of it can be on one line if you so choose. Incidentally, there is no need for a space inbetween the colon and the value as well.

List of Properties and Values

Single bullets show properties, indented bullets show values. Some properties are grouped if they take the same type of values.

  • font-family – also known as the "font face".
    • Many font types. Check out Microsoft Word's list – over 90% of those fonts are compatible.
  • font-size
    • ___% increases the font as a ratio to the default font size. There is also px and pt – px is actual pixels and pt is as it would appear in MSWord.
  • font-style – sets italics.
  • font-variant
  • font-weight &nash; sets bold.
    • normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900
  • font – declares all of the above in one statement...
    • ...in the order of font-style, font-variant, font-weight, font-size, and font-family: font: italic small-caps lighter 13px Arial;
  • text-align
    • left, center, right, justify
  • text-decoration – sets underline.
    • none, underline, overline, line-through, blink
  • text-transform – sets caps
    • none, capitalize, uppercase, lowercase
  • color, border-color
  • border-style
    • none, dotted, dashed, solid, double, groove, ridge, inset and outset
  • border-width
    • thin, medium, thick; or uses pixels, suggested that they are only positive integers – decimals such as 1.5 causes two sides to be 1px and two sides to be 2px
  • border, border-top, border-bottom, border-left, border-right
    • Unique shorthand way to define width, style, and color in one declaration: border: 1px dashed black;, border: 2px solid #289;. Only one side can be affected by using the last four properties if one so chooses.1
  • background, background-color, background-image
    • Can be a color value OR a complete url – background:url(http://www.imagesite.com/youralbum/bgpic.jpg);
  • background-repeat – image only.
    • repeat, repeat-x, repeat-y, no-repeat; with x being repeating horizontally only and y being repeating vertically only.
  • background-attachment – image only as well; sets whether the background scrolls with the page or not.
    • scroll, fixed
  • margin, margin-top, margin-bottom, margin-left, margin-right – Margin sets space between elements themselves. Honestly, it won't be used that much on a wiki.
    • Margin has a lot of measurements (px, em, cm, etc) but all do the same (ie a paragraph with a margin-bottom of 100px would look separated from the other paragraphs).
  • padding, padding-top, padding-bottom, padding-left, padding-right – Padding sets space in between the border of an element and its text.
    • Pixels only. Here decimals are OK.
  • list-style-image – This is special for the ul (unordered [bullet] list) selector, and can change the 5X5 pixel bullet image. More on this below.
    • url(url);
  • list-style-type – This is special for the li (ordered list) selector, and can change the numbers to:
    • decimal (default), lower-roman (i, ii, v), upper-roman (I, II, V), lower-alpha (a, b, c), upper-alpha (A, B, C)
  • -moz-border-radius, -moz-border-radius-topleft, -moz-border-radius-bottomleft, -moz-border-radius-topright, -moz-border-radius-bottomright – this Firefox-only property cuts off corner[s] at the edge of a table by a specified amount – that is, making the edge rounded.
    • Takes pixels or ems. One em is – wide (yes, the em dash is the long dash standardly used on this wiki).

1There are properties such as border-left-width, border-bottom-style, border-right-color as well.

List of Selectors

Keep in mind that a) some selectors will only take certain values (experiment!), b) many selectors will have specific names, unique to wikis, and c) Wayoshi's example provided eight common selectors. Those selectors all take font, color, and text-decoration values.

  • p – common paragraph. Used in raw websites from HTML, and used as a compound on wikis.
  • #content, #content table, #p-cactions ul li a – grouped together for a reason, see below.
  • .usermessage – the message table that appears when your talk page has been revised.
  • #p-logo a – the logo. Code for changing the logo is found below. (background)
  • textarea – Edit box. Code that utilizes the Mario bg we use now can be found at MediaWiki:Monobook.css.
  • pre – the table used inbetween <pre> tags.
  • ul – unordered (bullet) list
  • li – ordered (number) list
  • h1, h2, h3, h4, h5, h6 – in order: Title of Page, Section Header, Sub-Section Header, – matching to as number of = used in wiksyntax.
  • #catlinks – the table that contains categories.
  • #siteNotice – as says.
  • select – dropdown menus.
  • input – input boxes, like Summary.
  • input.searchButton – the buttons such as "Go" and "Save page".
  • #searchinput – specific selector for the search box.