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

การปิดใช้งาน Scroll Anchoring ด้วย CSS

เพื่อปิดใช้งานการจับตำแหน่งเลื่อน (scroll anchoring) เริ่มต้นที่เบราว์เซอร์ให้ เราสามารถใช้คุณสมบัติ overflow-anchor ได้

ตัวอย่าง

<!DOCTYPE html> 
<html> 
<head> 
<style> 
body { 
  overflow-anchor: none; 
} 
div{ 
  display: flex; 
  flex-direction: row; 
} 
</style> 
</head> 
<body> 
<div><img src="https://images.unsplash.com/photo-1613061588991-6dd130548bc7?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=400&ixlib=rb1.2.1&q=80&w=160" /> 
<img src="https://images.unsplash.com/photo-1612129717112-9d1274034547?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=400&ixlib=rb1.2.1&q=80&w=160" /> 
<img src="https://images.unsplash.com/photo-1613079936591-8ce270890241?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=400&ixlib=rb1.2.1&q=80&w=160" /> 
<img src="https://images.unsplash.com/photo-1612454902143-328050834c9e?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=400&ixlib=rb1.2.1&q=80&w=160" /> 
</div> 
<h2>Test overflow</h2> 
</body> 
</html>

ผลลัพธ์

จะได้ผลลัพธ์ดังนี้:

การปิดใช้งาน Scroll Anchoring ด้วย CSS