Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

background semitransparent div

Tags:

html

css

I want to show some dialog (absolute positioned div), and I want to show it above semitransparent 100% div, so everything on background will be dimmed. I have managed it by

<div class='transpBox'></div>

.transparentBox
{
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    background-color: #white;
    opacity: 0.9;
    z-index: 499;
}

This is all right, but when dialog height is more than browser height and you scroll down, you see that transparent div is not in full screen. What is proper way to make such thing?

like image 383
user283010 Avatar asked Mar 10 '26 03:03

user283010


2 Answers

Instead of position: absolute, use position: fixed. (Use it with your dialog div too.)

absolute positions based on the page, fixed positions based on the window.

like image 178
Casey Chu Avatar answered Mar 12 '26 22:03

Casey Chu


maybe you should try jquery modal dialogs. Rather than creating your own process in doing it. DOing so will give you the semitransparent background and a dialog foreground.

like image 23
Hanseh Avatar answered Mar 12 '26 20:03

Hanseh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!