Categories
- Ajax (1)
- Bisdak Blogger (1)
- chicks (1)
- Coffee and Paste (1)
- css (5)
- Excel (1)
- General Info (5)
- HTML (1)
- javascript (7)
- more (8)
- MySQL (1)
- pdf (1)
- Photoshop (1)
- PHP (26)
- SEO (1)
- sports (2)
Blog Archive
-
►
2009
(37)
-
►
March
(13)
- strlen vs isset in PHP
- 40 Tips for optimizing your php code
- $HTTP_SERVER_VARS
- Cross browser compatibility test site
- Detecting Mobile Browsers in PHP
- Passing JavaScript variables to PHP
- single-quote( ' ) vs double-quote ( " ) in PHP
- PHP Arrays
- Advantages of Using Functions
- Differences between constants and variables
- $_GET vs $_POST in PHP Forms
- require() vs include() in PHP
- What does !important mean in CSS?
-
►
February
(12)
- Javascript onclick return false does not work in I...
- Coffeeandpase Blogger: A Heavy Downloader
- Where is php.ini?
- Make a face
- Turn your photo into a cartoon
- Retrieving Japanese Text from MySQL using PHP
- CSS Play: Experiments with CSS
- New Online MD5 Hash Cracker!
- PNG Alpha Transparency Fix in IE
- Blogger.com as a website instead of a blog?
- Email address validation using Javascript
- PHPMailer: SMTP Authentication
-
►
March
(13)
-
▼
2008
(14)
-
►
December
(8)
- Simple php pagination
- Create Image Thumbnails Using PHP and GD
- How to create a dynamic bar graph using PHP and GD...
- How to create a dynamic line graph using PHP and G...
- Simple PHP Image Watermark
- Manny Pacquiao vs Oscar De la Hoya (The Dream Matc...
- Live free streaming!!! Pacquiao vs. De La Hoya
- Javascript equivalent for PHP Functions
-
►
December
(8)
Blog Roll
- Monkeetech
- Atenean101
- Batangsaag.blogspot.com
- Batangyagit.com
- Bethelo
- beyond-the-norms.org
- Brightartclass.blogspot.com
- Bugits
- Cebu Directories
- Cebudaily.com
- CebuElection
- Cebuheritage.com
- Cebuimage.blogspot.com
- Cebupacificairlines.ph
- Codes Depot
- Dahonglaya.com
- Empressofdrac
- Errol Duazo
- EUTS
- Iamdownloader.com
- Ibeejing
- Icymartagimacruz
- Ie-student
- In-indie.org
- Jerry Gervacio
- Lagahit.com
- Marian Calago
- Marroxas2010
- Mcbilly.com
- Miongandmarquee
- Nurseter
- Pinoyworld.org
- Punkies07
- QueerChef
- rentale
- Sinjin.ph
- softwareportables
- Sunchoke.net
- VeganPrince
- Vera
- Veryducky
- Yugatech
Centering a popup div using css
Before, I was centering a div using javascript and it sucks and gives a lot of hassle then I found this script(about four months ago) which takes away all my headaches. Makes life 0.00000001% easier....hehe
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>coffee and paste - popup div center</title>
<style>
html, body {
height:100%;
}
#blackout {
visibility: hidden;
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: none;
background-color: #000;
filter: alpha(opacity=80);
-moz-opacity: .8;
opacity: .8;
z-index: 9;
}
#divpopup{
position: fixed;
top: 50%;
left: 50%;
margin-top: -81px; /*half of the height plus a little to the top*/
margin-left: -150px; /*half of the width */
visibility: hidden;
display: none;
border: 1px solid #000;
background-color: #FFF;
color: #333;
padding: 0;
height: 150px;
width: 300px;
z-index: 10;
font-family: "Trebuchet MS", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
#divpop_head{
position:absolute;
top:0;
left:0;
width:100%;
background-color: #999999;
text-align:center;
padding:2px 0;
z-index:-1;
}
#close_pop{
float:right;
text-align:right;
cursor:pointer;
padding-right:10px;
}
#close_pop a{
text-decoration:none;
color: #333;
}
#close_pop a:hover{
color:#FF0000;
}
#pop_content{
clear:both;
padding: 10px;
}
</style>
<!--[if IE]>
<style type="text/css">
* {
padding: 0;
margin: 0;
}
html, body {
height: 100%;
overflow: auto;
}
#blackout {
position: absolute;
}
#divpopup {
position: absolute;
}
</style>
<![endif]-->
<script language="javascript" type="text/javascript">
function popup(sw) {
if (sw == 1) {
// Show popup
document.getElementById('blackout').style.visibility = 'visible';
document.getElementById('divpopup').style.visibility = 'visible';
document.getElementById('blackout').style.display = 'block';
document.getElementById('divpopup').style.display = 'block';
} else {
// Hide popup
document.getElementById('blackout').style.visibility = 'hidden';
document.getElementById('divpopup').style.visibility = 'hidden';
document.getElementById('blackout').style.display = 'none';
document.getElementById('divpopup').style.display = 'none';
}
}
</script>
</head>
<body>
<div id='blackout'> </div>
<div id='divpopup'>
<div id='divpop_head'>Coffee and Paste</div>
<div id='close_pop'onclick='popup(0)'><a href='#'>[close]</a></div>
<div id='pop_content'>
Thanks for visiting my blog....<br />
<a href='http://coffeeandpaste.blogspot.com/'>visit it again here </a><br />
<a href='http://monkeetech.blogspot.com/'>or my other blog here </a><br />
</div>
</div>
<a href='javascript:popup(1);'>Click here to test popup</a>
</body>
</html>
copy and paste the code above and paste it to your text editor and save it as html.
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>coffee and paste - popup div center</title>
<style>
html, body {
height:100%;
}
#blackout {
visibility: hidden;
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: none;
background-color: #000;
filter: alpha(opacity=80);
-moz-opacity: .8;
opacity: .8;
z-index: 9;
}
#divpopup{
position: fixed;
top: 50%;
left: 50%;
margin-top: -81px; /*half of the height plus a little to the top*/
margin-left: -150px; /*half of the width */
visibility: hidden;
display: none;
border: 1px solid #000;
background-color: #FFF;
color: #333;
padding: 0;
height: 150px;
width: 300px;
z-index: 10;
font-family: "Trebuchet MS", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
#divpop_head{
position:absolute;
top:0;
left:0;
width:100%;
background-color: #999999;
text-align:center;
padding:2px 0;
z-index:-1;
}
#close_pop{
float:right;
text-align:right;
cursor:pointer;
padding-right:10px;
}
#close_pop a{
text-decoration:none;
color: #333;
}
#close_pop a:hover{
color:#FF0000;
}
#pop_content{
clear:both;
padding: 10px;
}
</style>
<!--[if IE]>
<style type="text/css">
* {
padding: 0;
margin: 0;
}
html, body {
height: 100%;
overflow: auto;
}
#blackout {
position: absolute;
}
#divpopup {
position: absolute;
}
</style>
<![endif]-->
<script language="javascript" type="text/javascript">
function popup(sw) {
if (sw == 1) {
// Show popup
document.getElementById('blackout').style.visibility = 'visible';
document.getElementById('divpopup').style.visibility = 'visible';
document.getElementById('blackout').style.display = 'block';
document.getElementById('divpopup').style.display = 'block';
} else {
// Hide popup
document.getElementById('blackout').style.visibility = 'hidden';
document.getElementById('divpopup').style.visibility = 'hidden';
document.getElementById('blackout').style.display = 'none';
document.getElementById('divpopup').style.display = 'none';
}
}
</script>
</head>
<body>
<div id='blackout'> </div>
<div id='divpopup'>
<div id='divpop_head'>Coffee and Paste</div>
<div id='close_pop'onclick='popup(0)'><a href='#'>[close]</a></div>
<div id='pop_content'>
Thanks for visiting my blog....<br />
<a href='http://coffeeandpaste.blogspot.com/'>visit it again here </a><br />
<a href='http://monkeetech.blogspot.com/'>or my other blog here </a><br />
</div>
</div>
<a href='javascript:popup(1);'>Click here to test popup</a>
</body>
</html>
copy and paste the code above and paste it to your text editor and save it as html.
This entry was posted on Saturday, November 22, 2008
and is filed under
css
,
javascript
,
more
.
You can follow any responses to this entry through
the RSS 2.0 feed.
You can leave a response,
or trackback from your own site.
Posted on
-
5 Comments
Subscribe to:
Post Comments (Atom)



5 comments:
hi.
cre for x links?^^
cool blog name. :-)
How do you designate multiple divs on the same page for this?
If I want like 10 different divs on 10 different links on the same page...how do I change the code?
I will use only one popup div then load a dynamic content to it. But if you want it to be all html, then you can add nine more javascript popup function which makes your codes unpleasant to look at .
Anyway, hope that helps.
more web development tutorials here..
In IE7/6, the DIV id close_pop do not appears. All the other browsers it works awesome! Anyway to fix it?
Post a Comment