Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to design a CSS for a centered floating confirm dialog?

Tags:

I'm looking for a way to display a confirm dialog that's always centered on the page, and floating over the page.

Tried that, but it's not 'always centered' at all, since the position is fixed:

.Popup {     text-align:center;     position: absolute;     bottom: 10%;     left: 27%;     z-index:50;     width: 400px;     background-color: #FFF6BD;     border:2px solid black; } 

Any idea? Thanks

like image 705
Vinzz Avatar asked Jul 30 '09 09:07

Vinzz


People also ask

How do I center a dialog box in CSS?

To resolve this behavior and make the dialog to be viewed on the screen even on scrolling, set the dialog control wrapper CSS position as fixed and mention the top value. This will make the dialog to be shown in center of screen on scrolling the content of the web page.

How do I center a centered element in CSS?

Center Align Elements To horizontally center a block element (like <div>), use margin: auto; Setting the width of the element will prevent it from stretching out to the edges of its container.

How do you center text float in CSS?

There is no way to float center in CSS layout. So, we can center the elements by using position property. Example 1: This example set the position of elements exactly at the center of the screen.

How do I center a float div in CSS?

You can set float div center by using margin property. you does not need to use float property but you can use margin property and set left or right margin value auto by this way.


1 Answers

Try using this CSS

#centerpoint {     top: 50%;     left: 50%;     position: absolute; }  #dialog {     position: relative;      width: 600px;     margin-left: -300px;      height: 400px;     margin-top: -200px; } 
<div id="centerpoint">     <div id="dialog"></div> </div> 

#centerpoint should be the container div of the dialog

Note that the #centerpoint DIV should be inside the body element or inside elements that don't have a position: relative; property

like image 193
Cristian Toma Avatar answered Oct 01 '22 15:10

Cristian Toma