cssレイアウト2

3258 ワード

中央揃え

  • 常用中央
  • elemP{
      text-align: center;	
    }
    elelmP elemC{
      display: inline-block;	
    }
    elemP{
      display: table;
      margin-left: auto;
      margin-right: auto;
    }
    elelmP elemC{
      display: table-cell;	
    }
    elemP{
      height: Xpx;
      line-height: Xpx;
    }
  • ぜったいポジショニングセンターテクノロジ
  • 容器内中央
  •        elemP{
             position: relative;
             height: 100px; //      
           }
           elelmP elemC{
             position: absolute;
             margin: auto;
             width: ;         //           
             height: ;
             overflow: auto;  //       
             top: 0;
             left: 0;
             bottom: 0;
             right: 0;
           }
    *      
          elemC{
            position: fixed; //
            z-index: 9999;   //
            margin: auto;
            width: ;        
            height: ;
            overflow: auto;  
            top: 0;left: 0;bottom: 0;right: 0;
          }
    *      
          elemC{
            position: absolute;
            margin: auto;
            width: ;        
            height: ;
            overflow: auto;  
            top: 0;left: 0;bottom: 0;right: 0;
            left/right/top/bottom: auto;  //
          }
    *     
          elemC{
            position: absolute;
            margin: auto;
            width: ;        
            height: ;
            overflow: auto;  
            top: 0;left: 0;bottom: 0;right: 0;
            min-width: ; //  
            max-width: ; //  
          }
  • その他の中央技術
  • 負の外角//固定幅に属する場合
  •     elemC{
          width: ;
          height: ;
          padding: ;  
          position: absolute;
          top: 50%; left: 50%;  
          margin-left: -px; /* (width + padding)/2 */  
          margin-top: -px; /* (height + padding)/2 */  
        }
    *     
        elemC{
          width:;
          height: ;    
          position: absolute;
          margin: auto;
          top: 50%; left: 50%;  
          transform: translate(-50%,-50%);  
          -webkit-transform: translate(-50%,-50%);  
          -ms-transform: translate(-50%,-50%);  
        }

    レイアウト


    フローティングレイアウト

  • float:floatの設定は周囲要素
  • に影響することに注意する.
  • clear:フローティングレイアウト後、ラップ要素にclear:bothを設定して他の要素への影響を除去しますが、
    .clearfix:after{
      content: "";
      display: block;
      clear: both;
      visibility: hidden;	
    }
  • の方法がより一般的です.

    box-sizing

  • content-box:(デフォルト)
  • element値=content(text)+padding+border+margin;
  • border-box:(IE伝統ボックスモデル)
  • element値=content(text+padding+border)+margin;
  • inherit(継承)
  • あふれ出る


    overflow

  • visible:内容を切り取らないことに注意
  • auto:スクロールバー
  • を超える
  • hidden:超えると隠す
  • scroll:スクロールバー
  • を追加

    text-overflow(overflow:hidden;を設定してから意味があることに注意)

  • clip:デフォルト
  • ellipsis:非表示にすると、超過部分に省略記号
  • が表示されます.

    white-space

  • nowrap:1行
  • に強制表示