Typical DIV + CSS layout (left, right)

Typical DIV + CSS layout - fixed width and centered layout , the use of a floating property; this example, the use of the absolute positioning properties.

1, set #container in "position: relative;", whose role is to make absolutely positioned behind the baseline to #container browser rather than their prospective.

2, the left and right columns #left_side #right_side column absolute positioning, and the two fixed-width div, and the middle column is automatically adjusted due to the need #content browser, is not set similar properties.

However, since the other two blocks of the position property absolute, it must be the case margin-left and margin-right properties are set to 190px

 

 Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" Debug="true" StylesheetTheme="Default" %>  
  
<!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>左中右版式</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div id="wrap">  
        <div id="header">header</div>  
        <div id="container">  
            <div id="left_side">left_side</div>  
            <div id="content">content</div>  
            <div id="right_side">right-side</div>  
        </div>  
        <div id="footer">footer</div>  
    </div>  
    </form>  
</body>  
</html>
#wrap{  
    width:700px;  
    margin:0 auto;  
}  
#header{  
    margin:20px;  
    height:80px;  
    border:solid 1px #0000FF;  
}  
#container{  
    position:relative;  
    margin:20px;  
    height:400px;  
}  
#left_side{  
    position:absolute;  
    top:0px;  
    left:0px;  
    border:solid 1px #0000FF;  
    width:170px;  
    height:100%;  
}  
#content{  
    margin:0px 190px 0px 190px;  
    border:solid 1px #0000FF;  
    height:100%;  
}  
#right_side{  
    position:absolute;  
    top:0px;  
    right:0px;  
    border:solid 1px #0000FF;  
    width:170px;  
    height:100%;  
}  
#footer{  
    margin:20px;  
    height:80px;  
    border:solid 1px #0000FF;  
}  

 

 

Published 139 original articles · won praise 13 · views 9298

Guess you like

Origin blog.csdn.net/qq_18671415/article/details/103971538