2

I've got some code which I've needed to customise

my html

<div class="text-rotator add-top-half add-bottom-half align-left white-txt medium-txt uppercase highlight-bg">
    <div class="rotator-wrap" style="display: block;">
        <span class="rotate">Creating designs!</span>
    </div>
</div>

my css is:

.text-rotator {
    line-height: 80px!important;
    display: inline!important;
}

.text-rotator span {
    background: #3399ff!important;
    filter: alpha(opacity=60);
    -moz-opacity: 0.6;
    opacity: 0.6;
}

But at the moment it is setting the opacity of the text as well as the background and I cannot work out how to leave the text and just change the background.

Any ideas?

Totally Tech IT
  • 77
  • 1
  • 2
  • 6
  • There is a few questions already on StackOverflow, a quick search on google or even here and you would find out them. – dippas Jun 27 '16 at 12:50

4 Answers4

4

Use the following CSS:

.text-rotator span {
 background-color:rgba(255,0,0,0.3);/*background color and opacity together*/
 }
Sanjeev Kumar
  • 3,113
  • 5
  • 36
  • 77
2

Use RGBA color value for background:

.text-rotator {
    line-height: 80px !important;
    display: inline !important;
}

.text-rotator span {
    background: rgba(51, 153, 255, 0.6) !important;
}
<div class="text-rotator add-top-half add-bottom-half align-left white-txt medium-txt uppercase highlight-bg">
    <div class="rotator-wrap" style="display: block;">
        <span class="rotate">Creating designs!</span>
    </div>
</div>
Mohammad Usman
  • 37,952
  • 20
  • 92
  • 95
0

Common problem. The opacity is applied to all child elements. A workaround is to use rgb color codes. Not all browser support rgba so you should define fallbacks as well.

/* Fallback for web browsers that don't support RGBa */
background-color: rgb(0, 0, 0);
/* RGBa with 0.6 opacity */
background-color: rgba(0, 0, 0, 0.6);
/* For IE 5.5 - 7*/
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);
/* For IE 8*/
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000,endColorstr=#99000000)";
oshell
  • 8,923
  • 1
  • 29
  • 47
0

Use the following,

.text-rotator span.rotate {background:rgba(0,0,0,0.5);}