Opacitate doar la fundal

Coduri intrebari, probleme legate de HTML, XHTML si CSS
alexinio3d
Mesaje: 96

Opacitate doar la fundal

Salutare.
Cum pot pune o opacitate pe fundal fara sa afecteze si textul ??
Siteuri create / configurate de mine :
SilvoProject.Ro ( Magazin Online ) : SilvoProject.Ro
TreiSute.Ro ( Comunitate de gaming ) : TreiSute.Ro

MarPlo Mesaje: 4343
Incearca cu rgba() in css, editezi culorile Rosu, Verde, Alpastru si Alfa (opacitate):

Cod: Selectaţi tot

#id_elm {
  background: rgb(54, 25, 25); /* Fall-back for browsers that don't support rgba */
  background: rgba(54, 25, 25, 0.5);
}
Sau cu 2 Div-uri in unul:
HTML

Cod: Selectaţi tot

<div id="container">
  <div id="block"></div>
  <div id="text">Test</div>
</div>
CSS

Cod: Selectaţi tot

#container {
  position: relative;
  width: 300px; height: 200px;
}
#block  {
  background: #CCC;
  filter:alpha(opacity=60); /* IE */
  -moz-opacity:0.6; /* Mozilla */
  opacity: 0.6; /* CSS3 */
  position: absolute;
  top: 0; left: 0;
  height: 100%; width:100%;
}
#text {
  position: relative;
  margin: 0;
}

Subiecte similare