• html元素固定


    1、position

    描述
    static        默认。位置设置为 static 的元素,它始终会处于页面流给予的位置(static 元素会忽略任何 top、bottom、left 或 right 声明)。
    relative     位置被设置为 relative 的元素,可将其移至相对于其正常位置的地方,因此 "left:20" 会将元素移至元素正常位置左边 20 个像素的位置。
    absolute   位置设置为 absolute 的元素,可定位于相对于包含它的元素的指定坐标。此元素的位置可通过 "left"、"top"、"right" 以及 "bottom" 属性来规定。
    fixed        位置被设置为 fixed 的元素,可定位于相对于浏览器窗口的指定坐标。此元素的位置可通过 "left"、"top"、"right" 以及"bottom" 属性来规定。不论窗口滚动与否,元素都会留在那个位置。工作于 IE7(strict 模式)。

    2、z-index 属性设置元素的堆叠顺序。值越高越靠前面,仅能在定位元素上奏效(position:xx)

    <html>
    
    <head>
        <title>Only fit FireFox! :(</title>
        <!--Some thing about the fixed style!-->
        <style type="text/css">
            .fixed_div {
                position: fixed;
                left: 35%;
                top: 30px;
                width: 400px;
                z-index: 1;
            }
        </style>
    </head>
    
    <body>
        <div class="fixed_div" style="border:1px solid #200888;">content, I'm content</div>
        <div style="height:888px;background:yellow;"></div>
    </body>
    
    </html>
  • 相关阅读:
    Firefox常用web开发插件
    引用MFC指针的获取(转载)
    J2EE的13种核心技术(转载)
    用Visio画ER图的解决方案(转载)
    [导入]六一
    [导入]独自等待
    [导入]随想
    [导入]小聚
    [导入]网站需求分析
    [导入]如何做好网站开发项目需求分析
  • 原文地址:https://www.cnblogs.com/xbblogs/p/7118344.html
Copyright © 2020-2023  润新知