কম্পিউটার টিউটোরিয়াল

CSS-এ Background Attachment সেট করা

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 খুবই জনপ্রিয়।

  1. CSS দিয়ে ব্যাকগ্রাউন্ড কালারের ওপাসিটি সেট করুন

  2. CSS দিয়ে নেভিগেশন বার পেজের উপরে ফিক্স করা

  3. CSS-এ লিনিয়ার গ্রেডিয়েন্ট ব্যাকগ্রাউন্ড ইমেজ হিসেবে সেট করা

  4. CSS-এ রেডিয়াল গ্রেডিয়েন্ট ব্যাকগ্রাউন্ড ইমেজ সেট করুন