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

CSS position: relative


ตำแหน่งสัมพัทธ์ (Relative Positioning)

position: relative ย้ายองค์ประกอบจากตำแหน่งปกติโดยใช้ top, right, bottom, left โดยไม่ส่งผลต่อองค์ประกอบอื่น

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <style>
    div {
      position: relative;
      left: 20px;
      border: 3px solid blue;
    }
  </style>
</head>
<body>
  <h1>Positioning Element</h1>
  <div>div element with position: relative;</div>
</body>
</html>