Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-04-2011, 09:24 AM   PM User | #1
Asher01
New Coder

 
Join Date: Jul 2011
Location: Australia
Posts: 47
Thanks: 1
Thanked 3 Times in 3 Posts
Asher01 is an unknown quantity at this point
opacity

If I have a first element with an opacity attributed to it and I place a second element inside/on top of the first one.... how can I make the second element non-opacity?
__________________
“Opinion is the medium between knowledge and ignorance.”
“The old believe everything; the middle aged suspect everything: the young know everything.”
Asher01 is offline   Reply With Quote
Old 09-04-2011, 09:37 AM   PM User | #2
vikram1vicky
Regular Coder

 
Join Date: Jul 2011
Location: India
Posts: 496
Thanks: 3
Thanked 57 Times in 56 Posts
vikram1vicky is an unknown quantity at this point
With positioning and z-index properties it is possible.... but position value can be absolute only and parent element of both elements should have position:relative defined to it

vikram1vicky is offline   Reply With Quote
Old 09-04-2011, 09:41 AM   PM User | #3
coothead
Senior Coder

 
coothead's Avatar
 
Join Date: Jan 2004
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 1,551
Thanks: 0
Thanked 195 Times in 191 Posts
coothead will become famous soon enough
Hi there Asher01,

here is a basic example...
Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="language" content="english"> 
<meta http-equiv="Content-Style-Type" content="text/css">
<title>untitled document</title>

<style type="text/css">
body {
    background-color:#00f;
 }
#container {
    position:relative;
    width:440px;
    margin:auto;
 }
#faded {
    width:400px;
    height:360px;
    padding:40px;
    background-color:#f00;
    border:4px solid #000;
    opacity:0.30;
    filter:alpha(opacity=30);
    font-size:30px;
    font-weight:bold;
    text-align:center;
 }
#unfaded {
    position:absolute;
    z-index:1;
    left:84px;
    top:189px;
    width:300px; 
    padding:10px;   
    border:2px solid #000;
    font-size:30px;
    font-weight:bold;
    text-align:center;
    background-color:#fff;
 }
</style>

</head>
<body>

<div id="container">

<div id="faded">this area is effected by opacity</div>

<div id="unfaded">this area is unaffected</div>

</div>

</body>
</html>
coothead
coothead is offline   Reply With Quote
Old 09-04-2011, 09:41 AM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,601
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
You can’t since opacity is always inherited. If the parent has 80% opcacity and the child 100% opacity then all in all it’s still 80% (100% of 80% is still 80%, and there is no more than 100% opacity). Depending on what you are trying to achieve you may be able to use an RGBA background color on the parent (“A” standing for “alpha value”, i. e. transparency), like background-color: rgba(255,255,255,.5); but this won’t work in IE. Alternatively you can make the child a sibling of the parent and position it absolutely on top of it.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 09-04-2011, 10:33 AM   PM User | #5
Asher01
New Coder

 
Join Date: Jul 2011
Location: Australia
Posts: 47
Thanks: 1
Thanked 3 Times in 3 Posts
Asher01 is an unknown quantity at this point
Oh OK, I see... that makes perfect sense now that you say that.

I'll have to do something like Coot's example... find the first non-opacity and then work from that.

Thank you, all three of you.
Cheers!
Asher
__________________
“Opinion is the medium between knowledge and ignorance.”
“The old believe everything; the middle aged suspect everything: the young know everything.”
Asher01 is offline   Reply With Quote
Old 09-04-2011, 10:39 AM   PM User | #6
coothead
Senior Coder

 
coothead's Avatar
 
Join Date: Jan 2004
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 1,551
Thanks: 0
Thanked 195 Times in 191 Posts
coothead will become famous soon enough
No problem, you're welcome.
coothead is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:21 AM.


Advertisement
Log in to turn off these ads.