实例
.header{ width:100%; background-color:lightblue; } .header .context{ width:600px; height:60px; background-color: lightseagreen; margin:0 auto; } .header .context .nav{ margin: 0px; padding:0px; } .header .context .nav .item{ margin: 0px; padding:0px; list-style: none; position: relative; } .header .context .nav .item a{ float:left; min-height: 30px; min-width: 70px; height: 30px; width:70px; line-height: 30px; text-align:center; margin:5px; padding:5px; text-decoration-line: none; } .contain{ min-height:390px; width:600px; margin:6px auto; } .contain .wp{ background-color:#ccc; min-height: inherit; width:inherit; } .contain .left{ background-color:#D2B48C; width:150px; min-height: 380px; margin-left:-100%; } .contain .right{ width:150px; background-color:#DC143C; min-height: 380px; margin-left:-150px; } .wp ,.left,.right{ float:left; } .contain .wp .context{ padding-left:160px; } .footer{ width:100%; background-color:lightblue; } .footer .context{ width:600px; height:60px; background-color:lightseagreen; margin:0 auto; } .footer .context p{ text-align:center; line-height:60px; } .footer .context p a{ text-decoration-line:none; }
点击 "运行实例" 按钮查看在线实例
体会:1主内容居中,margin:0 auto;
2.双飞翼注意事项,div块级元素的浮动,使用margin-left和margin-right进行变动,
3.中间部分使用双div嵌套,防止内边距变动对左右两边造成影响;内容居中使用padding-left和padding-right变动到合适位置,