美文网首页
css脱离文档流的中间布局

css脱离文档流的中间布局

作者: 小白脸开红花 | 来源:发表于2017-07-25 10:15 被阅读0次

    position:fixed;position:absolute;都适用

    html内容:

    <div>123</div>

    div {

    background:#777;

    position: fixed;

    margin:auto;

    left: 50%;

    top:50%;

    transform:translateY(-50%) translateX(-50%);

    }/*不设长宽在中间 ie9以上正常*/

    /* div {

    width: 100px;

    height: 100px;

    background:#777;

    position: fixed;

    margin:auto;

    left: 50%;

    top:50%;

    transform:translateY(-50%) translateX(-50%);

    } *//*ie9开始在中间*/

    /* div {

    width: 100px;

    height: 100px;

    background:#777;

    position: fixed;

    margin:auto;

    left: 0;

    right: 0;

    top:0;

    bottom: 0;

    } *//*ie8开始在中间*/

    相关文章

      网友评论

          本文标题:css脱离文档流的中间布局

          本文链接:https://www.haomeiwen.com/subject/pqcwkxtx.html