Reputation: 33
I Have Written The Following Code . It Is Showing Absolutely Fine In Mozilla and Chrome . But IN Internet Explorer , it is not center aligned and display at the left side . Here Is The Code:
<html>
<head>
<title>ProgramEngine Website Registration</title>
<style type="text/css">
div#login
{
background-color:#f1f1f1;
width: 510px;
height: 1024px;
border: 1px solid grey;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<div id="login"></div>
</body>
</html>
So Can AnyBody Suggest Me What is the Problem And How To Overcome It.
Upvotes: 3
Views: 1496
Reputation: 5746
You can use jquery for good solution.
$(document).ready( function(e){
var screen = $('body').width();
screen -= 51; //51 is width of div
screen /= 2;
$('#login').offset({top:0,left:screen});
});
if you need use top in offset value.
Here, browser can't makes problem.
Upvotes: 4
Reputation: 839
Are you using correct DOCTYPE? Without the DOCTYPE, IE automatically goes into Quirks render mode - this is your problem, probably.
Upvotes: 3