0

I have a container for which I have set the opacity to 0.6 in css. I have another div inside the above container where I have some text with color:white say "MY TEXT". Now the problem is this text is getting fade as I want only the outer container to fade with opacity not the text. Can someone please help.

Below is the html code :

<div id='cover-part' style='text-align:center1;padding:15px'> <div id='opaque-cover-part'> <div id='cover-part-text'><span>THIS TEXT SHOULD NOT FADE</span></div> </div> 

Below is the CSS

#cover-part{ position: relative; background: url(posts/images/1.jpg) no-repeat 0 center, linear- gradient(white, black); height:250px; } #cover-part-text{ position:relative; font-size: 30px; color:#FFFFFF; left: 0px; bottom:0px; font-weight:bold; display:block; z-index:2; font-family: helvetica, arial, sans-serif; height:100px; width:100%; padding-left:15px; padding-top:15px; } #opaque-cover-part{ position: absolute; left: 0px; bottom:0px; height:100px; width:100%; background:linear-gradient(black, black); opacity:0.6; filter:alpha(opacity=50); z-index:1; } 
2
  • Related - stackoverflow.com/questions/806000/… Commented Feb 22, 2016 at 20:36
  • You can move the #cover-part-text out from the #opaque-cover-part, and make it positioned absolute, over the #opaque-cover-part in the same place. Commented Feb 22, 2016 at 22:40

2 Answers 2

0

It's very simple you can just add a class or id in your span where the elements that have this class aren't opaqued.

working-example:

https://plnkr.co/edit/5jbyZv609LEaKBctKFC1?p=preview

eg:

.not-opaque{ opacity:1; } 

and

<span class='not-opaque'>THIS TEXT SHOULD NOT FADE</span> 
Sign up to request clarification or add additional context in comments.

1 Comment

this not working mate.
0

Just add opacity: 1; to your inside container;

https://plnkr.co/edit/6o33hFTwmBoAv16alfca

4 Comments

try to make the backgound of the page black, to see if more clearly
my background is an image, I don't want it black
just do it for test purposes. The container more whiter makes the text more invisible.
tried. still no luck

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.