Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Ralf Koller
4,506 PointsType gets semitransparent too on semitransparent div overlay
That is kind of a confusing behaviour. i have something like that:
<section class="fp-about">
<img class="imgtest" src="<?php bloginfo('template_directory'); ?>/img/about.jpg" alt="about test">
<div class="abox">
<h3 class="mus-hi abox-title">Über uns</h3>
<p class="bran-rn abox-info">Worf, It's better than music. It's jazz. I'll alert the crew. How long can two people talk about nothing? Earl Grey tea, watercress sandwiches... and Bularian canapés? Are you up for promotion? Now, how the hell do we defeat an enemy that knows us better than we know ourselves? That might've been one of the shortest assignments in the history of Starfleet.</p>
</div>
</section>
The CSS looks like that:
.fp-about {
position:relative;
padding:0;
}
.abox {
background-color:$lightblue;
height: 100%;
width:100%;
@include breakpoint(750px){
width:50%;
}
position:absolute;
top:0;
left:0;
opacity: .8;
}
Basically it should be an image. On the mobile view an light blue overlay with an opacity of .8 should cover the entire image, after the breakpoint it should be covered only 50% in height. But the problem is the typo (h3 and p) is adapting the opacity and is also half see through even if i set the opacity of h3 to 1:
h3.abox-title {
opacity: 1;
}
is it due to that h3 and p are basically child elements of the semi transparent abox div? And is there a way to work around that issue elegantly? Best regards Ralf
2 Answers
Sam Lillicrap
12,127 PointsI've a little trouble understanding your problem - but I think you're referring to the text taking on the opacity of it's parent elements.
I might be wrong but I think you'll have to place your h3 outside of these elements on which you've specified an opacity if you want it to take on it's own opacity value. Either that or you use photoshop to edit your image to look like that and not use opacity on a light blue box.
Hope this helps!
Also a little tip with your Sass - if I were you I'd try not to name your variables '$lightblue' or any actual colours, as this defeats the point of it being a variable, and can get quite confusing if you change the colour to another colour. Maybe try something like '$box-color'
Ralf Koller
4,506 Pointshi sam thanks for the answer! well the problem is / was mainly that the typo tags h3 and p inherited the opacity of its containing parent div.
about your reply. i think i will go with your suggestion not to use the opacity property, it seems way too thin ice. ;) but i don't want to place my typo tags outside an empty div just for the sake of getting a semi transparent overlay. but had another idea i completely forgot. used an rgba value on the abox background-color. that did the trick. and since i don't care for ie8 and below that solution might work just fine in the long run. ;))
and about the sass part. thanks, true. normally i use a binary specification. first I define the colors like $lightblue: #5FBCD3 and then asign $infobox: $lightblue;. but since it was just a quick codesnippet i left the plain color variable in. it's easier to read if you see $lightblue in a plain snippet than an abstract $infobox variable. ;) best regards ralf
