Discuti il tutorial sul forum !

Creare un elemento html semi trasparente

Make HTML Elements Semi-Transparent
By Bret Taylor, July 23, 2006
Internet Explorer does not support the opacity CSS property like Firefox and Safari. The solution is (as usual) to take advantage of IE filters to acheive a similar effect. This simple function sets opacity/transparency correctly across all modern browsers:

function setOpacity(element, opacity) {
    if (navigator.userAgent.indexOf("MSIE") != -1) {
        var normalized = Math.round(opacity * 100)
        element.style.filter = "alpha(opacity=" + normalized + ")";
    } else {
        element.style.opacity = opacity;
    }
}

This example usage sets the opacity of the given element to 50%:

setOpacity(document.getElementById("image2"), 0.5);

You can also set the opacity properly with static CSS if that is appropriate for your project. This CSS snippet is equivalent to the line of JavaScript above:

#image2 {
  filter: alpha(opacity=50);
  opacity: 0.5;
}

Fonte: http://ajaxcookbook.org/html-element-transparency/

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Reddit
  • scuttle
  • Smarking
  • Spurl
  • YahooMyWeb
  • DZone
  • Internetmedia
  • Snap2r
  • Technorati


Correlati


Commenti

Scrivi un commento





Commenti recenti:


Ultimi dal forum

Selezionando contrassegno si aggiungono spese al totale
Ho inserito postepay come pagamento
Inserire metakeywords
Problemi di installazione
Scaricare correttore ortografico italiano
Vari problemi
Installazione su server remoto
Installazione
Problema aggiornamento quantità prodotti carrello
Info
Bug utente + suggerimento formattazione
Problema cancellazione dalla mailing list
Problemi login
Problemi di visualizzazione nella home page
Fireworks appiattisce livelli quando salvo in png