Lightbox JS 2 Overlay Opacity

Geplaatst in CSS, Webdesign Reeds 9 reacties op dit bericht

Today I’ve spent over an hour searching how the background opacity with the lightbox JS 2 has been implemented. I wanted to change the opacity from 80% to 40% or less since one of our clients requested so.

What does one do first when one wants to change some layout elements? Check out the CSS stylesheets, and yes. There are three lines defined in the #overlay declaration:

filter:alpha(opacity=80);
-moz-opacity:.80;
opacity:.80;

How convenient, lets just cut all values in half and the opacity of the background overlay should turn more transparent, no? Wrong!

Apparently these CSS styles are only defined to support the script degrading gracefully, in javascript enabled browsers it doesn’t serve any active use, you could leave the styles out and the script would still be fully functional. But how do we change the opacity then? Well after some digging through the javascript code it ends up being fairly straightforward. Just open lightbox.js and search for the following line (it’s around line 320 depending on which version of lightbox JS 2 you are using)

new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8 });

The red value is the value you wanna change to manipulate the transparency or opacity of the page overlay. Pretty easy to change if you know where to look.

I hope I saved some of you some time with this. It could prove usefull if Lokesh Dhakar, the creator of this fabulous script, would include some configuration directives in the top of the script controlling the behaviour and style of the lightbox.


Reacties

  1. 1
    Sun 09 Jul
    Grahame zei:

    Thanks mate,
    Had been looking for the same thing but had come up with a blank,other than the CSS.
    I don’t speak javascript too well ;)
    As per seek an ya can find some clever bugger that has solved the problem for you.
    Am looking at using Lightbox for my galleries but just need to work out the ways to entice it to do things to my “visions”.
    Sheesh it’s great “out of the box”,beats the hell out of 10 images,10 pages to present them.
    And with far more style than popups.
    One more thought solved.
    Cheers,
    Grahame.

    05:05
  2. 2
    Wed 24 Jan
    Buddy zei:

    Thanks, saved me some time.

    19:21
  3. 3
    Thu 16 Aug
    Luis Nunes zei:

    Thanks a lot mate, really useful :)

    22:37
  4. 4
    Wed 13 Feb
    LWD zei:

    Thanks!
    Javascript is still a foreign language to me, so this really helped! :)

    10:05
  5. 5
    Wed 21 May
    Deano zei:

    Thank you so much :) I’ve been pulling my hair out for a while on this!

    14:43
  6. 6
    Fri 04 Jul
    Justin B zei:

    Thanks, that’s really useful!

    16:57
  7. 7
    Tue 15 Jul
    Barbara zei:

    Thanks! This was very helpful.

    18:38
  8. 8
    Fri 17 Oct
    aya zei:

    Thanks so much for sharing this tip. Definitely saved me some time. Cheers!

    21:02
  9. 9
    Tue 04 Nov
    Claire zei:

    Just what I needed – Thanks. Been looking for that for flippin’ ages :)

    15:13

Reageer

XHTML: Je mag volgende XHTML tags gebruiken: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>