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

ตั้งค่าระยะขอบด้านบนขององค์ประกอบด้วย CSS


margin-top ระบุระยะขอบด้านบนขององค์ประกอบ สามารถมีค่าความยาว % หรืออัตโนมัติ คุณสามารถลองเรียกใช้รหัสต่อไปนี้เพื่อตั้งค่าระยะขอบบน:

ตัวอย่าง

<html>
   <head>
   </head>
   <body>
      <p style = "margin-top: 10px; border:2px solid red;">
         This is a paragraph with a specified top margin
      </p>
      <p style = "margin-top: 10%; border:2px solid green;">
         This is another paragraph with a specified top margin in percent
      </p>
   </body>
</html>