I searched the web for solutions but none centered this horizontally on the page. I tried
margin-right: auto; and margin-left: auto; and tried margin 0 auto:
What’s the solutions?
Thanks.
.container10
{
border:1px solid #000000;
background: #00FF00;
padding:0px 0px 0px 0px;
width:980px;
height:264px;
margin:0px 0px 0px 0px;
}
PaulOB
March 28, 2013, 3:10pm
2
HI,
Margin:auto is all you need on a non positioned element that has a width defined.
e.g.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
.container10 {
border:1px solid #000;
background:#0f0;
padding:0;
width:980px;
height:264px;
margin:0 auto;
}
</style>
</head>
<body>
<div class="container10"></div>
</body>
</html>
You must use a valid doctype or IE reverts to quirks mode and won’t center.