Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

ตำแหน่ง CSS:สัมบูรณ์;


ตำแหน่ง :สัมบูรณ์; คุณสมบัติช่วยให้คุณสามารถวางตำแหน่งองค์ประกอบที่สัมพันธ์กับบรรพบุรุษตำแหน่งที่ใกล้ที่สุด

ตัวอย่าง

คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้ตำแหน่ง CSS:absolute;

<!DOCTYPE html>
<html>
   <head>
      <style>
         div.one {
            position: relative;
            width: 500px;
           height: 150px;
           border: 2px solid blue;
         }
         div.two {
            position: absolute;
            top: 70px;
            right: 0;
            width: 300px;
            height: 50px;
            border: 2px solid yellow;
         }
      </style>
   </head>
   <body>
      <h2>position: absolute;</h2>
      The position: absolute; property allows you to position element relative to the nearest positioned ancestor.
      <div class = "one">div has position: relative;
         <div class = "two">div has position: absolute;</div>
      </div>
   </body>
</html>