Aug 06 2016 0

Revising method for adding drop shadows

After removing the jQuery code for the archives page I reviewed the code I have been adding to the script scripts.js in order to determine if even more code can be removed and replaced with just CSS. And there was.

The focus this time was on the code I added to add drop shadows to images that are ending with -ds. Using a selector based on the src attribute for img elements it is possible to recreate this feature by just using CSS.

Updated CSS

Old CSS code 727

/* Dropshadows */
.dropshadow {
  box-shadow: 0 0 20px 0 rgba(0,0,0,0.4);

Updated CSS code (not the . after -ds) 727

/* Dropshadows */
img[src*="-ds."] {
  box-shadow: 0 0 20px 0 rgba(0,0,0,0.4);

Removed jQuery code


// Add dropshadow to images ending with `-ds`
$('img').each(function() {
    var filename = $(this).attr('src');
    var imgName = filename.substr(0, filename.lastIndexOf('.')) || filename;

    if ( imgName.substr(imgName.length - 3) == '-ds' ) {

Previous post
Revising the archives page The last time I have updated the design (somewhere in September 2015) for the Archives page I added some jQuery code so you could expand/collapse
Next post
Rikomagic MK06 I have always had a liking for miniature things. As a kid I didn’t want a train of the HO scale (1:87), but had my mind set on Minitrix or Trix for
This blog is powered by Blot