20181207_Second_小結

1. 上下 200*200 盒子的重疊,切記用 absolute 絕對定位 爲最佳解決方案css

 

2. 移動端多使用 粘連佈局html

  • <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8"/>
            <title></title>
            
            <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
            <meta name="viewport"
                  content="user-scalable=no,
                           width=device-width,
                           initial-scale=1.0,
                           minimum-scale=1.0,
                           maximum-scale=1.0"/>
            
            <style rel="stylesheet" type="text/css">
                html, body, div {
                    margin: 0;
                    padding: 0;
                } html, body { width: 100%; height: 100%; /* 參照屏幕區域的高 */
                    min-width: 600px; overflow: hidden;
                } #wrap { width: 100%; min-height: 100%; // 使 footer 始終在屏幕的底部
                    
                    background: cadetblue;
                } #content { width: 100%; padding-bottom: 50px;
                    
                    font-size: 14px;
                    background: darkgrey;
                } #footer { // 必須放在 wrap 的外面 width: 100%; height: 50px; margin-top: -50px;
                    
                    background: chocolate;
                    text-align: center;
                    line-height: 50px;
                }
            
            </style>
        </head>
        
        <body>
            
            <!-- 模擬屏幕區域 -->
            <div id="wrap">
                <!-- 內容區域 -->
                <div id="content"></div>
            </div>
            
            <!-- 底部區域 -->
            <div id="footer"></div>
        </body>
    </html>

 

3. 瀏覽器有 兩個 滾動條瀏覽器

  • 單獨給 html 或者 body 加 overflow: scroll;        都會做用在 document 上,生成一個滾動條
  • 同時給 html、body 加 overflow: scroll;        會出現兩個滾動條
  • html 的 overflow: scroll; 會做用於 document
  • body 的 overflow: scroll; 會做用於 body

 

4. 在子元素浮動時,解決父元素高度塌陷佈局

(1) 給父元素設置固定 heightui

 

(2) 使 父元素 開啓 BFCspa

父元素 overflow: hidden;scala

父元素 也 浮動 float代理

絕對定位 position: absolute;code

固定定位 position: fixed;htm

IE6 開啓 BFC :  zoom: 1;

(3) 使用 塊元素 隔離 父、子元素

⑤ 添加一個換行

  • <div id="wrap">
        <div id="box"></div>
        <br clear="all">    
    </div>

⑥ 添加一個空的 <div> 清除浮動 clear: both;

⑦ 僞元素 before 轉換爲 塊

  • .clearfix:after {    /* 僞元素默認是 inline 行內元素 */
        content:"";    /* 充當父元素的最後一個子元素,默認是 inline 行內元素, 至關一個 <span></span> */
        display: block;   /* 將 僞元素設置爲 block 塊級元素  */
        clear: both;
    }

 

5. 初始包含塊

根元素的包含塊        // 大多數狀況 <html>就是根元素

初始包含塊 由用戶代理創建

大多數瀏覽器中,初始包含塊就是一個視窗大小的矩形,但不等同於視窗        // 視窗就是瀏覽器窗口

  • 對於 非根元素 ,
  • 若 position: relative/static,包含塊是最近的行內塊祖先元素的 內容邊界 構成
  • 若 position: relative/absolue/fixed,包含塊是最近的開啓了定位的祖先元素
  • 若沒有祖先元素,則元素的包含塊爲初始包含塊 <html>
相關文章
相關標籤/搜索