不是说子元素的absolute 定位是body(非特殊情况)?以下怎么是针对父元素定位的?

<head>

<title>test absolute</title>

<style type="text/css">

    *{margin:0; padding: 0;}

   

    .box {

        width: 100%;

        height: 100px;

        background-color: pink;

    }


    .one {

        width: 500px;        

        border: 10px solid black;

        background-color: green;

       

    }

    .two {

        width: 100px;

        height: 100px;

        background-color:yellow;

        position: absolute;

        border: 10px solid red;

    }

</style>

</head></head>

<body>

<div class="box">

    </div>

<div class="one">

        <div class="two"></div>

    </div>


</body>


慕仰4388114
浏览 1256回答 1
1回答

ZE明

absolute定位是根据最近的有带position的父元素定位的,你这里父元素没写position,应该是相对于body定位的吧

慕田峪6141110

WCELXVUHXQQRHAVCIVLRYKEDZWVLIEXUQQFIYRMNZCNDXKKQEKGPSWMBDWCMVTTGFMMFEUBKOOKANEFYPOKEXAOKKNSXBUXXKHWPLUUTGAMIPCLUGJNDADJPCIRWTPIQCIFLMFOUEZVQCFCPBKAXKWYAUGEXRAGGZBRQGMGZPDCCSVBYHAMTSPLVVLQNMZIJCYCFLRFPUUKDKGDTFXWPZIOIWSYIYATXGQWNQWMVKQQCCJNJMJXDFPZYIEHOHPRCJDJSFVOYATXDCZVCLWWIOUETULJFIVVEXIIOODQTXOXAQTISIDGIKSBMIYBKTILFOQTQFPYBDAIXZJMIFMPLUEFUKGXGIFOKUENWMIVYOXGMIRUCZCFUKOHKTCLOEHWGEDGTQYBRGWFOWFHQTCYBRUQRGJMQFPSOEHPENXMVXNCZVSNDZPYVCFPSTSBBYXAWTTFXNPLIWGCRHQZPYUJGWMIWFLHPMVRBLHQSNDLVXIDGPSUDTOYGJZOJGIHQMVLNDZVYBTJLHRTIWTCRAQLBRUEBXGURADMVYHQTWSBCZCROJGWEBDNWZPFOKTPFLHDTWLVKADFGILOKUKNVLIGPSORNKOKGDJDGKADNDZIMMOQGQGVFHXTBQZVMVSBVYOSPEUXGIZHLOFVQGXAQZVXUFAJZIFISBRAJZBXAPRHXAJFICYBETJZVRILNJNQZVYMBIXZJFVRHDZPUXMWSVWLVYHDKTWSUXNXZPYTDMDGJGGJZKGCFAPSWFPLXMBRNXNKKAKTCLHYHXGDTCXTCYNQZILODISUJSBXAPMVMOKAWENWSVEFUJTPTPFIYGZVPLUEMJLBXJFVLMIYOKAWJFHETCLBLHVTPKUPFUXGWMHGZWFLOMPFS

hahhhha

position: relative;

慕仰4388114

但是我这个是定位在父元素的左上,不是浏览器的左上
打开App,查看更多内容
随时随地看视频慕课网APP