zoukankan      html  css  js  c++  java
  • CSS负边距自适应布局三例

    单列定宽单列自适应布局:

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset=”UTF-8″>
    <title>单列定宽单列自适应布局</title>
    <style type=”text/css”>
    * {margin:0;padding:0;}
    .cont, .side {float:left;}
    .cont {width:100%;}
    .main {margin-right:200px;background:#DDDDDD;}
    .side {margin-left:-200px;width:200px;background:#F7F7F7;}
    </style>
    </head>
    <body>
    <div class=”cont”>
    <div class=”main”>main</div>
    </div>
    <div class=”side”>side</div>
    </body>
    </html>

    左右定宽中间自适应布局:

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset=”UTF-8″>
    <title>左右定宽中间自适应布局</title>
    <style type=”text/css”>
    * {margin:0;padding:0;}
    .cont, .side, .sub-main {float:left;}
    .cont {width:100%;}
    .main {margin-right:200px;margin-left:300px;background:#DDDDDD;}
    .side {margin-left:-200px;width:200px;background:#F7F7F7;}
    .sub-main {margin-left:-100%;width:300px;background:#F7F7F7;}
    </style>
    </head>
    <body>
    <div class=”cont”>
    <div class=”main”>main</div>
    </div>
    <div class=”side”>side</div>
    <div class=”sub-main”>sub-main</div>
    </body>
    </html>

    两列等高自适应布局:

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset=”UTF-8″>
    <title>两列等高自适应布局</title>
    <style type=”text/css”>
    * {margin:0;padding:0;}
    .layout {overflow:hidden;}
    .cont, .side {float:left;padding-bottom:9999px;margin-bottom:-9999px;}
    .cont {width:100%;}
    .main {margin-right:200px;background:#DDDDDD;}
    .side {margin-left:-200px;width:200px;background:#F7F7F7;}
    </style>
    </head>
    <body>
    <div class=”layout”>
    <div class=”cont”>
    <div class=”main”>
    main
    <br/><br/><br/><br/><br/><br/><br/>
    </div>
    </div>
    <div class=”side”>side</div>
    </div>
    </body>
    </html>
  • 相关阅读:
    JS 中如何判断字符串类型的数字
    使用script的src实现跨域和类似ajax效果
    JS跨域(ajax跨域、iframe跨域)解决方法及原理详解(jsonp)
    IOS上架截屏 屏幕快照
    IOS 证书失效
    80端口占用
    PHP环境 PDOException PDOException: could not find driver
    分布式部署
    AES 加密算法 跨语言
    AES 加密填充 PKCS #7
  • 原文地址:https://www.cnblogs.com/jdsm/p/3522572.html
Copyright © 2011-2022 走看看