S
Steve Richter
in the following code I expect the inner div to be centered within the
outer div. problem is, it doesn't.
basically, the margin settings of the inner div are not recognized
when display:inline is used. When the inner div is display:block, the
top and bottom margins are recognized, but the div width is the width
of the containing div, so there is no centering.
<div style="height:8em; margin:1em; border:dotted 1px orange;">
<div style="margin-top:1em;margin-bottom:1em;margin-left:auto;margin-
right:auto;
display:inline; background-color:LightBlue;">
abc efg
</div>
</div>
why would display:inline cause the margins of the div to be ignored?
thanks,
here is the complete html:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default7.aspx.cs" Inherits="Default7" %>
<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<div style="height:8em; margin:1em; border:dotted 1px orange;">
<div style="margin-top:1em;margin-bottom:1em;margin-left:auto;margin-
right:auto;
display:block; background-color:LightBlue;">
abc efg
</div>
</div>
</body>
</html>
outer div. problem is, it doesn't.
basically, the margin settings of the inner div are not recognized
when display:inline is used. When the inner div is display:block, the
top and bottom margins are recognized, but the div width is the width
of the containing div, so there is no centering.
<div style="height:8em; margin:1em; border:dotted 1px orange;">
<div style="margin-top:1em;margin-bottom:1em;margin-left:auto;margin-
right:auto;
display:inline; background-color:LightBlue;">
abc efg
</div>
</div>
why would display:inline cause the margins of the div to be ignored?
thanks,
here is the complete html:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default7.aspx.cs" Inherits="Default7" %>
<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<div style="height:8em; margin:1em; border:dotted 1px orange;">
<div style="margin-top:1em;margin-bottom:1em;margin-left:auto;margin-
right:auto;
display:block; background-color:LightBlue;">
abc efg
</div>
</div>
</body>
</html>