Note: You are currently viewing documentation for Moodle 2.2. Up-to-date documentation for the latest stable version is available here: Replacing icons with CSS.

Replacing icons with CSS: Difference between revisions

From MoodleDocs
(a start on this topic)
 
(Shifted to dev docs)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
It is possible to '''replace icons with CSS'''. You can also place [[alternate icon set]] files within your theme's folder but this has some drawbacks compared with the [[CSS]] approach.
{{Moved_to_dev_docs}}
 
* you must use .gif files
* the images must be the same size (in some cases), namely 16x16 pixels
* you can't switch images via javascript/mouseover/rollovers/alternate stylesheets etc.
* you can't make the images part of the clickable area of associated links
 
On the other hand, the drawbacks of the CSS approach are:
 
* the old icons are still downloaded, and part of the HTML even though they are not displayed
* it may not work in every case (investigations still ongoing)
 
 
 
== How to replace icons with CSS ==
 
=== Removing current icons ===
 
The first step to providing alternative icons via CSS, is to hide the current icons.
 
==== removing sideblock icons ====
 
    .sideblock .c0 {display: none;}
 
==== removing activity and resource icons ====
 
    .activity img.activityicon {display: none;}
 
==== icons that can't currently be replaced ====
 
* course requires enrollment key icon
* course allows guest access icon
 
==== oddities, problems, issues ====
 
* you can't have different icons for each different resource type (e.g. pdf, weblink, text resource)
 
=== Applying new icons ===
 
The next stage is to apply new icons. These will be added as background images, that occupy the left hand side of the associated link tag, with the text moved along to the right.
 
==== adding sideblock icons ====
 
...
 
==== adding activity and resource icons ====
 
    td.activity > a {background-repeat: no-repeat; padding-left: 20px;}
 
Then each individual activity icon needs to be located e.g.
 
    <nowiki>td.activity.glossary > a {background-image: url(http://moodle.org/mod/glossary/icon.gif);}</nowiki>
 
(this code only works on Firefox and other browsers that support child selectors, there is a workaround but it's fairly ugly. I will add this once it is fine tuned)
 
[[Category:Administrator]]
[[Category:Themes]]
[[Category:Developer]]

Latest revision as of 08:05, 22 June 2011

This development related page is now located in the Dev docs.

See the Replacing icons with CSS page in the Dev docs.