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

ตำแหน่งสัมพัทธ์ใน CSS


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

ตัวอย่าง

เรามาดูตัวอย่างกัน −

<!DOCTYPE html>
<html>
<head>
<style>
div.demo {
   position: relative;
   color: white;
   background-color: orange;
   border: 2px dashed blue;
   left: 50px;
}
</style>
</head>
<body>
<h2>Demo Heading</h2>
<p>This is demo text.</p>
<p>This is demo text.</p>
<div class="demo">
position: relative;
</div>
<p>This is another demo text.</p>
</body>
</html>

ผลลัพธ์

ตำแหน่งสัมพัทธ์ใน CSS