问答详情
源自:3-1 Overflow与块状格式上下文

position: absolute ??? 没有使用场景, are you kidding me!

bull shit!

absolute error!

.conatiner{
    position: relative;
}
.box{
    position: absolute;
    width: 50%;
    height: 50%;
    background: red;
    transform: translateX(50%), translateY(50%);
}

提问者:UFO2015 2017-01-16 01:35

个回答

  • 网友张顺飞
    2021-05-18 15:39:30

    人老师说的是两栏自适应布局不适合使用absolute,你整个绝对居中,闹哪样啊??

  • UFO2015
    2017-01-16 01:39:53

    https://learning.xgqfrms.xyz/CSS3/float%20&%20position/absolute-center.html

  • UFO2015
    2017-01-16 01:38:14

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>absolute-center</title>
        <style>
            .box2{
                width: 50%;
                height: 50%;
                background: red;
                position: absolute;
                transform: translateX(50%) translateY(50%);
            }
        </style>
    </head>
    <body>
        <div>
            <!-- 50% x 50% center-->
        </div>
    </body>
    </html>