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

บทบาทของคุณสมบัติมาร์จิ้นที่มีค่าสืบทอดโดยใช้ CSS


คุณสมบัติมาร์จิ้นที่มีค่าสืบทอดถูกใช้เพื่อสืบทอดองค์ประกอบจากองค์ประกอบหลัก คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้งาน margin:inherit;

ตัวอย่าง

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            border: 2px solid blue;
            margin-left: 50px;
         }
         p.ex1 {
            margin-left: inherit;
         }
      </style>
   </head>
   <body>
      <p>Inheriting left margin from the parent element</p>
      <div>
         <p class = "ex1">This is demo text with inherited left margin.</p>
      </div>
   </body>
</html>

ผลลัพธ์

บทบาทของคุณสมบัติมาร์จิ้นที่มีค่าสืบทอดโดยใช้ CSS