zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    Palindrome Partitioning
    Minimum Path Sum
    Maximum Depth of Binary Tree
    Minimum Depth of Binary Tree
    Unique Binary Search Trees II
    Unique Binary Search Trees
    Merge Intervals
    Merge Sorted Array
    Unique Paths II
    C++ Primer Plus 笔记第九章
  • 原文地址:https://www.cnblogs.com/xbblogs/p/7118344.html
Copyright © 2011-2022 走看看