zoukankan      html  css  js  c++  java
  • css面试题

    1.盒子垂直居中的方法

    #box{
            400px;
            height:400px;
            position:absolute;
            top:50%;
            left:50%;
            margin-left:-200px;
            margin-top:-200px;
            background:#000;
        }

    2.CSS实现首尾高度固定、中间高度自适应的DIV布局

    <!doctype html>
    <html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <title>Document</title>
    </head>
    <body>
        <div class="con">
            <div class="top"></div>
            <div class="md"></div>
            <div class="bottom"></div>
        </div>
        
        <style>
            *{margin:0; padding:0;}
            html,body,.con{height:100%;100%;height:100%;100%;}            
            div{position:absolute;}
            .top,.bottom{100%;height:100px;z-index:5;}
            .top{background:red;top:0;}
            .bottom{background:black;bottom:0;}
            .md{
                 100%;
                 background:#a7fad7;
                 overflow:auto;
                 top:100px;
                 bottom:100px;
                 position:absolute;
                 _height:100%;
                 _border-top:-100px solid #eee;
                 _border-bottom:-100px solid #eee;
                 _top:0;/*http://www.cnblogs.com/ckmouse/archive/2012/02/14/2351043.html*/
            }
        </style>
    </body>
    </html>

    3.多行文字垂直居中
    li{
      display:table;
    }
    li>span{
      display:table-cell;
      vertical-align:middle;
    }

    4.设置图片宽度100%,高度等于宽度
    img{
      100%;
      height:0;
      padding-bottom:100%;
    }
    亦心晗
  • 相关阅读:
    react 之 ref
    再看redux
    localtunnel内网服务器暴露至公网
    Relay GraphQL理解
    微信小程序
    React Router
    webpack
    Redux
    bootstrap
    jQuery中.bind() .live() .delegate() .on()区别
  • 原文地址:https://www.cnblogs.com/wanf/p/7273644.html
Copyright © 2011-2022 走看看