- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hello I have some CSS where i want my div horizontally align in the dead center of the browser. The code i have works fine in Chrome and Firefox but aligns left in IE 8. code is below:
.center{
position:relative;
margin-left:auto;
margin-right:auto;
text-align:center;
top:116px;
width:963px;
height:257px;}
HELP
It centers OK horizontally, see here: http://jsfiddle.net/senff/8YbkP/
(For clarity, I’ve added a border to the DIV and I’ve reduced the size — a 963 px wide div wouldn’t fit in the box.)
There must be something else in your code causing the problem.
Thank you for pointing that out to me turns out the problem is i have some opening PHP which needs to be ahead of my DocType, adjusting creates a problem when i am doing a php redirect which sends an error that “Warning: Cannot modify header information – headers already sent”
my code:
require_once(“includes/functions.php”); ?>
When i put the DocType before the PHP it centers fine in IE, however when i put the PHP first it aligns left
In older IE, as you’ve discovered, nothing can come before the doctype or IE reverts to quirks mode and will not honor the auto margins. I don’t think the problem is the php, but the html