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

จัดองค์ประกอบในแนวตั้งใน CSS


หากต้องการจัดองค์ประกอบในแนวตั้งในแนวตั้งใน CSS ให้ใช้การเติมด้านบนและด้านล่าง

ตัวอย่าง

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

<!DOCTYPE html>
<html>
   <head>
      <style>
         .center {
            padding: 50px 0;
            border: 2px solid blue;
         }
      </style>
   </head>
   <body>
      <h2>Center Vertically</h2>
      <p>In this example, we use the padding property to center the div element vertically:</p>
      <div class = "center">
         <p>I am vertically centered.</p>
      </div>
   </body>
</html>

ผลลัพธ์

จัดองค์ประกอบในแนวตั้งใน CSS