• 网页html结构右侧栏固定,左侧自适应大小。


    最近写了一个项目,写页面的结构,html树形结构是有header,container,footer部分,其中container部分是右侧栏是固定宽度,左侧是自适应宽度与屏幕高度。

    第一次写的博客文章是container部分是左侧栏固定,右侧是自适应效果。左侧栏固定是很好写,但右侧栏固定却不很好写,以下是基本的结构与样式。

     <div class="container" style="overflow:hidden;">
            <div class="left leftCont">
            </div>
            <div class="right rightSide">
            </div>
    </div

    1.左右栏高度一定, 如果仍想按照左侧固定的模式写右侧固定的效果。可以如下写:

    可以看到container下的两个div进行了对调。

    <style type="text/css">
           
            .rightSide {
                width: 200px;
                height: 600px;
                background: red;
                float: right;
            }
            .leftCont {
                width: 100%;
                margin-right: 200px;
                background-color: blue;
                height: 600px;
            }
        </style>
    </head>
    <body>
        <div class="container" style="overflow:hidden;">
            <div class="rightSide">
            </div>
            <div class="leftCont">
            </div>
        </div>
    </body>

    2.如果不想将两个子div进行调换位置,则可以写如下代码,

      <style type="text/css">
            .rightSide {
                width: 200px;
                height: 600px;
                background: red;
                float: right;
            }
    
            .leftCont {
                float: left;
                width: 100%;
                margin-right: 200px;
                background-color: blue;
                margin-bottom: -2000px;
                padding-bottom: 2000px;
            }
        </style>
    </head>
    <body>
        <div class="container" style="overflow:hidden;">
            <div class="left leftCont">
            </div>
            <div class="right rightSide">
            </div>
        </div>
    </body>

    这样界面实现效果,并且左侧的高度大小跟右侧div的高度一样。 其中关键的两句话是:margin-buttom:-2000px; padding-buttom:2000px; 并且3000px不是固定的值,只要是比实际需求的高度大就ok。

  • 相关阅读:
    趁热讲讲skin.xml支持的标签和attributes
    如何配置和编译ogre 1.7.0 + cegui 0.7.1
    关于OGRE基础教程6中CEGUI的layout文件can not locate的问题
    skin.xml皮肤配置讲解
    OCX控件注册相关(检查是否注册,注册,反注册)
    重回博客园继续我的 GUI库
    窗口类的定义
    UI库需要完成的任务
    屏幕截图代码
    深入C++的默认构造函数1
  • 原文地址:https://www.cnblogs.com/pengpenglin/p/4251894.html
Copyright © 2020-2023  润新知