position_relative+absolute 搭配使用,實現絕對定位 放大縮小都不影響其絕對位置


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div style="position: relative; width:500px; height:200px; border: 1px red solid;margin: 0 auto; ">
        <div style="position: absolute; width:50px; height:50px; background-color:#411000; top: 0;left:0;"></div>
    </div>

    <div style="position: relative; width:500px; height:200px; border: 1px red solid;margin: 0 auto; ">
        <div style="position: absolute; width:50px; height:50px; background-color:#411000; bottom: 0;left:0;"></div>
    </div>

    <div style="position: relative; width:500px; height:200px; border: 1px red solid;margin: 0 auto; ">
        <div style="position: absolute; width:50px; height:50px; background-color:#411000; bottom: 0;right:0;"></div>
    </div>
</body>
</html>

<!--
relative+absolute 搭配使用,實現絕對定位  放大縮小都不影響其絕對位置
-->

效果:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM