zoukankan      html  css  js  c++  java
  • css自适应布局(两列自适应布局+三列左右固定中间自适应+三列中间固定左右自适应)

    1.两列自适应

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>demo</title>
    <style type="text/css" media="screen">
    #left{float: left;background: #ccc;height: 400px; 400px;}
    #right{background: green;height: 400px;position: absolute;left: 400px;right: 0;}
    </style>
    </head>
    <body>
    <div id="left"></div>
    <div id="right">11111<br>11111<br>11111<br>11111<br>11111<br></div>
    </body>
    </html>

      

    2.三列中间固定左右自适应

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    *{margin: 0;padding: 0;}
    #left{height: 300px;background: orange;float: left; 50%;position: relative;margin-left: -150px;}
    #right{height: 300px;background: orange;float: right; 50%;margin-left: -150px;}
    #center{ 300px;height: 300px;background: green;float: left;position: relative;}
    </style>
    </head>
    <body>
    <div id="left">
    </div>
    <div id="center">
    </div>
    <div id="right">
    </div>

    </body>
    </html>

    3.三列中间自适应,左右固定

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    *{margin: 0;padding: 0;}
    #left{ 300px;height: 300px;float: left;background: green;}
    #right{height: 300px;background: green; 300px;float: right;}
    #center{height: 300px;margin: 0 300px;background: #ccc;}
    </style>
    </head>
    <body>
    <div id="left">
    </div>
    <div id="right">
    </div>
    <div id="center">
    </div>
    </body>
    </html>

      

    每种自适应写了一种方案,欢迎补充!

    ------------------------------------------------------------------------------

    汗!不允许150个字内发布,那我就再写一种关于三列左右固定,中间自适应布局

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    *{margin: 0;padding: 0;}
    #left{ 300px;height: 300px;position: absolute;left: 0;background: green;}
    #right{height: 300px;background: green; 300px;position: absolute;right: 0;}
    #center{height: 300px;margin: 0 300px;background: #ccc;}
    </style>
    </head>
    <body>
    <div id="left">
    </div>
    <div id="right">
    </div>
    <div id="center">
    </div>
    </body>
    </html>

      

      

  • 相关阅读:
    文件比较运算符
    中山慧海人才市场9月份 现场招聘会预告
    80后智能科技公司诚聘业务人员
    元豪路灯厂诚聘
    对Discuz的简单认识
    discuz阅读权限的设置作用
    个人对织梦系统的认识
    awvs的用法
    cain使用方法
    CCNA笔记(1)
  • 原文地址:https://www.cnblogs.com/yanwei-sun/p/5271431.html
Copyright © 2011-2022 走看看