Solved

center CSS box on screen

Posted on 2007-11-15
3
4,551 Views
Last Modified: 2012-06-21
i need to center the CSS alert box on screen in any screen size, possible?


<style>
<!--Message box css-->
div#modalContainer { background-color:transparent; position:absolute; width:100%; height:100%; top:0px; left:0px;  z-index:10000; }
#alertBox { position:absolute; width:300px; min-height:100px; margin-top:50px; margin-left:9em; border:1px solid #000; background-color:#F2F5F6; z-index:12000; }
div#modalContainer > #alertBox { position:fixed; }
#modalContainer #alertBox h1 {color:#fff; margin:0; font-size:0.8em; background-color:#4e9600; border-bottom:1px solid #000; padding:5px; }
#alertBox p { font:0.7em verdana,arial; height:50px; padding-left:5px; margin-left:55px; }
#alertBox #closeBtn { color:#fff; display:block; position:relative; margin:5px auto; padding:3px; border:1px solid #000; width:70px; font-size:0.7em; text-transform:uppercase; text-align:center; background-color:#4e9600; text-decoration:none; }
</style>
0
Comment
Question by:pigmentarts
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
cezarF earned 500 total points
ID: 20288594
try this....

#alertBox {width:300px; height:200px; position:absolute; top:50%; left:50%; margin:-100px auto auto -150px; border:1px solid #000; background-color:#F2F5F6; z-index:12000; }
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 20289356
perfect, what did you change? thanks.
0
 
LVL 14

Expert Comment

by:cezarF
ID: 20289828
added the following

height:200px;
top:50%;
left:50%;
margin:-100px auto auto -150px;

and removed

min-height:100px;
margin-top:50px;
margin-left:9em;
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to represnt 52 selections 1 33
Hand when hover boostrap carrousel 6 31
Problem to page 4 23
Gradient CSS 4 14
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now