zoukankan      html  css  js  c++  java
  • css布局

    display(元素显示模式)

    display:block

    元素默认显示模式,在不设置任何display属性情况下元素被作为一个块对象占据整行,其他元素不能与它在同一行显示

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
                .div1 {
                    width: 200px;
                    height: 200px;
                    border: 1px solid black;
                    background: blue;
                    display: block;
                }
                .div2 {
                    width: 200px;
                    height: 200px;
                    border: 1px solid black;
                    background: yellow;
                }
        </style>
    </head>
    <body>
        <div class="div1"></div>
        <div class="div2"></div>
    </body>
    </html>

    display:none(隐藏对象)

    设置这个属性的元素在浏览器中被隐藏,其他元素可取代它原本的位置

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
                .div1 {
                    width: 200px;
                    height: 200px;
                    border: 1px solid black;
                    background: blue;
                    display: none;
                }
    
                .div3{
                    width: 200px;
                    height: 200px;
                    border: 1px solid black;
                    background: red;
                }
                .div2 {
                    width: 200px;
                    height: 200px;
                    border: 1px solid black;
                    background: yellow;
                }
        </style>
    </head>
    <body>
        <div class="div1"></div>
        <div class="div3"></div>
        <div class="div2"></div>
    </body>
    </html>

    display:inline-block

    与block相反,它允许其他元素在同一行显示

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
                .div1 {
                    width: 200px;
                    height: 200px;
                    border: 1px solid black;
                    background: blue;
                    display: inline-block;
                }
                .div2 {
                    width: 200px;
                    height: 200px;
                    border: 1px solid black;
                    background: yellow;
                    display: inline-block;
                }
        </style>
    </head>
    <body>
        <div class="div1"></div>
        <div class="div2"></div>
    </body>
    </html>

    float(元素浮动)

    当元素向左或向右浮动时,元素的显示属性也变化成相当于一个行内元素,个人认为相当于个一个表格的多个同个tr里的td,

    在html代码中元素的浮动从上至下依次进行,谁在上谁就先浮动

    被设置了float属性的元素会脱离文档流的显示规则,它只能浮动在左边或右边,如果在同一行内浮动的空间不足

    则自动转向下一行

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
                .div1 {
                    float: right;
                    width: 200px;
                    height: 200px;
                    border: 1px solid black;
                    background: blue;
                    
                }
                .div2 {
                    float: right;
                    width: 200px;
                    height: 200px;
                    border: 1px solid black;
                    background: yellow;
                    
                }
        </style>
    </head>
    <body>
        <div class="div1"></div>
        <div class="div2"></div>
    </body>
    </html>

    position(元素定位)

    positon:static (默认值,无定位)

    positon:absolute(绝对定位)通过脱离文档流来控制定位,以body为父元素来进行定位时:

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
                .div1 {
                    position: absolute;
                    top: 300px;
                    left: 400px;
                    width: 200px;
                    height: 200px;
                    border: 1px solid black;
                    background: blue;
                    
                }
                .div2 {
                    float: right;
                    width: 200px;
                    height: 200px;
                    border: 1px solid black;
                    background: yellow;
                    
                }
        </style>
    </head>
    <body>
        <div class="div1"></div>
        <div class="div2"></div>
    </body>
    </html>

    position:fixed(固定定位)

    固定定位的元素是相对于浏览器来设置的,它在浏览器窗口中的位置始终不变,即使页面被滚动条下拉,

    元素也会一直在原来相对的位置

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
                .div1 {
                    position: fixed;
                    top: 300px;
                    right: 0px;
                    width: 200px;
                    height: 200px;
                    border: 1px solid black;
                    background: blue;
                }
        </style>
    </head>
    <body>
        <div class="div1"></div>
    </body>
    </html>
  • 相关阅读:
    ArcGIS超级工具SPTOOLS-制图篇
    ArcGIS超级工具SPTOOLS-MXD操作篇
    ArcGIS超级工具SPTOOLS-影像的批量裁剪和批量合并
    Get Raster Properties获得栅格的信息
    ArcGIS超级工具SPTOOLS-按属性裁剪,矢量数据批量裁剪,矢量数据批量合库
    ArcGIS超级工具SPTOOLS-SHP转数据库,批量数据库转数据库,栅格彩色转黑白
    ArcGIS超级工具SPTOOLS-锐角检查,获得内角并判断是否凸多边形,获得线(面)两个折点方向
    ArcGIS超级工具SPTOOLS-线封闭,点集转面
    ArcGIS超级工具-征地部标准坐标导出导入 SPTOOLS
    arcgis的arcpy写入几何怎么创建一个空心面要素并读取几何和属性信息,根本不够管
  • 原文地址:https://www.cnblogs.com/zhongqiwei/p/5779243.html
Copyright © 2011-2022 走看看