Background attachment সেট করতে background-attachment property ব্যবহার করা হয়। এটি নির্ধারণ করে পটভূমির ছবি ফিক্সড থাকবে নাকি পেজের সাথে স্ক্রোল হবে।
উদাহরণ
নিচের কোডটি রান করে 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>
ব্যবহার: প্যারাল্যাক্স ইফেক্ট (parallax effect) তৈরির জন্য background-attachment: fixed খুবই জনপ্রিয়।