1

I created the popup for the facebook when the popup load the entire background is goes to something like color code #ccc; which can i view the inside content also. How can do this in css here is the code that i tried .

#ptechsolfb {display:none;
background-color:#ccc transparent;
width:100%;
height:100%;
position:fixed;
top:0;
left:0;
z-index:999999999;
opacity: 1; } 

How can i do this. Any One would be much appreciated.

5
  • dont keep opacity 1 .opacity 1 means transparent .. keep it something between .4 to .6 and see what happens Commented May 30, 2013 at 9:32
  • @Let'sCode no, opacity 0 means transparent. 1 is fully opaque. Commented May 30, 2013 at 9:34
  • check this stackoverflow.com/questions/806000/… Commented May 30, 2013 at 9:35
  • @NielsKeurentjes see this davidwalsh.name/css-opacity Commented May 30, 2013 at 9:36
  • 1
    @Let'sCode what's your point? That site also says "Opacity values must be anywhere from 0 (not visible) and 1 (completely visible)." So like I said, 0 is transparent, 1 is opaque. Commented May 30, 2013 at 10:00

6 Answers 6

3

The correct way to make only the background opaque would be to apply an rgba color:

background:rgba(204,204,204,0.5);

This is the equivalent of #ccc but semi-transparent because it has an alpha value of 0.5.

If you change the opacity value for the entire div its contents will also go semi-transparent, which is not the intended behaviour.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 Correct answer. However, please note that this won't work in IE8 or earlier (unless you use a polyfill)
3

Background opacity is achieved using rgba. For instance, this would create a black background (#000 or rgb(0,0,0)) with 50% (0.5) opacity:

element {
    background-color:rgba(0, 0, 0, 0.5);
}

JSFiddle example.

To give a background of #CCC (rgb(204, 204, 204)) 75% opacity, you'd use:

element {
    background-color:rgba(204, 204, 204, 0.75)
}

Comments

2

For background transparency, you need an rgba color definition. This would look like this:

background-color:rgba(200, 200, 200, 0.5);

Where the first three numbers are the red, green and blue components, and the fourth number is an opacity percentage for the 'alpha channel'.

However, please note that this syntax isn't supported in IE8 or earlier. It does work in pretty much all other current browsers, but IE8 support may be a problem for you.

If you need to support IE8, my suggestion is to use CSS3Pie, which is a polyfill script that adds support for this feature (and a load of other stuff) to old IE versions.

Hope that helps.

Comments

2

try something like this:

.Background
{
background-color:white;
background: rgba(0, 0, 0, 0.5);
}

1 Comment

+1 Correct answer. However, please note that this won't work in IE8 or earlier (unless you use a polyfill)
1

about the value for opacity:

"Specifies the opacity. From 0.0 (fully transparent) to 1.0 (fully opaque)"

Here is the link: http://www.w3schools.com/cssref/css3_pr_opacity.asp

AND it wont work like you wrote it:

background-color:#ccc transparent;

You have to remove the transparent atribute from background-color property:

background-color:#ccc;

Comments

1

If you want a (nearly) cross-browser solution, you can try:

.alpha60 {
    /* Fallback for web browsers that doesn't support RGBa */
    background: rgb(0, 0, 0);
    /* RGBa with 0.6 opacity */
    background: 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)";
}

Where for IE, the first Hex pair (99) controls the opacity.

Source here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.