পটভূমির ছবির স্ক্রোলিং নিয়ন্ত্রণ করতে background-attachment property ব্যবহার করা হয়। এই property-এর মাধ্যমে ছবিটি পেজের সাথে স্ক্রোল হবে (scroll) নাকি স্থির থাকবে (fixed) তা নির্ধারণ করা যায়।
উদাহরণ
নিচের কোডটি রান করে background-attachment property-র কাজ বুঝতে পারেন:
<!DOCTYPE html> <html>
<head>
<style>
body {
background-image: url('/css/images/css.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
}
</style>
</head>
<body>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
</body>
</html>
নোট: মূল উদাহরণে একই property দুবার লেখা ছিল (fixed এবং scroll), যা ভুল। শেষের মানই প্রয়োগ হয়। এখানে শুধু fixed রাখা হয়েছে।