|
| If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Post ye. code and I'll happily take a look!
1. I find that using the strict DTD and writing valid HTML cuts down on browser compatibility issues. I used to pull my hair out making IE and FF look the same, but since I started writing valid HTML with the strict DTD, I can't remember the last time I had a problem. 2. margin: auto (the way I normally center a div) only works when the div has an explicit width. 3. I don't think there's a standard way to center vertically that works in every browser. |
|
|||
|
Six or eight years ago I read a web page on how to center vertically.
Whatever the method was, it was very simple. I vaguely recall trying it in either IE or Netscape. I have not actually used it in any pages, though. -- Jeff, in Minneapolis
__________________
http://www.FreeMars.org/jeff/ "I find astronomy very interesting, but I wouldn't if I thought we were just going to sit here and look." -- "Van Rijn" "The other planets? Well, they just happen to be there, but the point of rockets is to explore them!" -- Kai Yeves |
|
|||
|
This sort-of works:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
background-color:#fcc;
}
div#center {
background-color:#fff;
width: 300px;
height: 300px;
margin: auto;
position: absolute;
top: 40%;
right: 40%;
bottom: 40%;
left: 40%;
}
</style>
</head>
<body>
<div id="center">
<p>The cake is a lie!</p>
</div>
</body>
</html>
|
|
||||
|
Right-o. Here's my sloppy, sloppy code (still trying to learn):
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="Style.css">
</head>
<body>
<p>
<span class="MainBoxSplash">
<map name="TableWorkaround">
<div class="SplashContent">
<table class="SplashTitle" border="0" rules="cols" frame="vsides">
<tr><td>Text</td></tr>
<tr><td><img id="SplashBadge" src="badge.gif" alt=""></td></tr>
<tr><td>Text</td></tr>
</table>
</div>
<p id="SplashSlash">
<a class="SplashLink" href="Link.htm">English</a>
/
<a class="SplashLink" href="Link.htm">Français</a>
</p>
</map>
</span>
</p>
</body>
</html>
Code:
body {
background-color: #660000;
text-align: center;
font-size: 100%;
}
div.SplashContent {
margin: 0px;
margin-top: 5px;
width: 460px;
background-color: #ffffff;
border-style: solid;
border-width: 1px;
font-size: 2em;
padding-top: 10px;
margin-left: 5px
}
img#SplashBadge {
border-style: solid;
border-color: #000000;
border-width: 0px;
margin: 0px;
margin-top: 10px;
}
p#SplashSlash {
margin-top: 7px;
font-size: 1.125em;
}
span.MainBoxSplash {
margin: auto;
width: 472px;
height: 330px;
background-color: #dddddd;
border-style: solid;
border-width: 1px;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
table.SplashTitle {
margin: 0px;
margin-left: auto;
margin-right: auto;
margin-bottom: 10px;
text-align: center;
border-width: 0px;
}
Edit: Tofu, just looked into your code. Interesting, but it isn't centred in either browser. Edit 2: I forgot to say that I ran both codes through the w3 validators. They passed.
__________________
Quaeso quousque humi defixa tua mens erit? Nonne aspicis, quae in templa veneris? |
|
||||
|
If you're using vertical-align or valign then that's the problem since it doesn't work well for divs in IE.
try to go with a table cell, or use absolute positioning: Code:
<html> <body leftmargin="0px" topmargin="0px"> Using absolute positioning <div style="width:300px;height:300px;border:solid 1px #000000;"> <div style="left:100px;top:100px;width:100px;height:100px;border:solid 1px #000000;position:absolute;z-index:2"> </div> </div> Using table cells <table cellspacing="0px"> <tr> <td align="center" valign="middle" width="300px" height="300px" style="border:solid 1px #000000"> <div style="width:100px;height:100px;border:solid 1px #000000;"></div> </td> </tr> </table> </body> </html>
__________________
And so it was, however late . . . |
|
|||
|
Quote:
In your css, the reason the box is flush-right in IE is because of the top, right, bottom, and left attributes for the span.MainBoxSplash class. If you change them to something like this: top: 30%; right: 30%; bottom: 30%; left: 30%; Then you can move the box out of the corner. But like my previous post, that's not a perfect solution. |
|
||||
|
Thanks for your help, guys. It turns out that a clever little workaround was just figured out here. Works perfectly.
__________________
Quaeso quousque humi defixa tua mens erit? Nonne aspicis, quae in templa veneris? |