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>
  • 相关阅读:
    SpringMvc完成ajax功能
    接收的参数为日期类型
    Mybatis的逆向工程(generator)以及分页助手(pageHelper)
    springMVC静态资源的映射
    Mybatis框架
    写一个简单的SpringMvc的demo
    SpringMvc流程
    controller进行数据保存以及如何进行重定向跳转
    我爱C语言
    三列布局中有两列内容固定
  • 原文地址:https://www.cnblogs.com/xbblogs/p/7118344.html
Copyright © 2011-2022 走看看