Aquesta pàgina forma part de la documentació de Moodle en català, tot i que no ha estat traduïda encara. Podeu contribuir obertament a les tasques de traducció. Podeu consultar la Guia d'edició de la documentació i també participar ens els debats del fòrum de traductors de la documentació a moodle.org

Replacing icons with CSS: diferència entre les revisions

De MoodleDocs
Salta a:navegació, cerca
mCap resum de modificació
Cap resum de modificació
Línia 3: Línia 3:
* you must use .gif files, which prevents you using alpha transparency available with .pngs
* you must use .gif files, which prevents you using alpha transparency available with .pngs
* you can't send different images to different browsers (e.g. .gifs to IE, .png to everyone else)
* you can't send different images to different browsers (e.g. .gifs to IE, .png to everyone else)
* the images must be the same size as the standard icons (in some cases at least), namely 16x16 pixels
* the images must be the same size as the standard icons (in most cases at least), namely 16x16 pixels
* you can't switch images via javascript/mouseover/rollovers/alternate stylesheets etc.
* 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
* you can't make the images part of the clickable area of associated links
Línia 10: Línia 10:


* the old icons are still downloaded, and part of the HTML even though they are not displayed
* 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)
* it may not work in every case (a more [[Replacing icons with CSS3|complete method using CSS3]] is available but only works in certain, newer browsers)





Revisió del 09:57, 30 abr 2006

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.

  • you must use .gif files, which prevents you using alpha transparency available with .pngs
  • you can't send different images to different browsers (e.g. .gifs to IE, .png to everyone else)
  • the images must be the same size as the standard icons (in most cases at least), 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 (a more complete method using CSS3 is available but only works in certain, newer browsers)


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

   .sideblock .c1 a {background-repeat: no-repeat; padding-left: 20px;}

Then each individual sideblock icon needs to be applied e.g.

    .block_course_list .c1 a {background-image: url(http://moodle.org/pix/i/course.gif);}

adding activity and resource icons

   td.activity > a {background-repeat: no-repeat; padding-left: 20px;}

Then each individual activity icon needs to be applied e.g.

   td.activity.glossary > a {background-image: url(http://moodle.org/mod/glossary/icon.gif);}

(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)