Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> JavaScript

CSS से पृष्ठभूमि अटैचमेंट सेट करें

पृष्ठभूमि अटैचमेंट सेट करने के लिए, background-attachment गुण का उपयोग करें। पृष्ठभूमि अटैचमेंट निर्धारित करता है कि पृष्ठभूमि छवि स्थिर है या शेष पेज के साथ स्क्रॉल होती है।

उदाहरण

निम्न कोड चलाकर background-attachment गुण का उपयोग करके निश्चित पृष्ठभूमि छवि सेट करना सीखें:

<!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>
  </body>
</html>
  1. - CSS से नेविगेशन बार को वेब पेज के टॉप पर फिक्स करें

    नेविगेशन बार को टॉप पर सेट करने के लिए, position: fixed प्रॉपर्टी का उपयोग top प्रॉपर्टी के साथ करें। टॉप पर रहने वाले मेनू को लागू करने के लिए निम्न कोड चलाकर देखें: उदाहरण <!DOCTYPE html> <html>    <head>       <style>         &

  1. - CSS से रैखिक ग्रेडिएंट को बैकग्राउंड इमेज के रूप में सेट करें

    CSS linear-gradient() फ़ंक्शन का उपयोग करके रैखिक ग्रेडिएंट को बैकग्राउंड इमेज के रूप में सेट करें। उदाहरण <!DOCTYPE html> <html>    <head>       <style>          #demo {             height: 200p

  1. - CSS के साथ रेडियल ग्रेडिएंट को पृष्ठभूमि छवि के रूप में सेट करें

    radial-gradient() CSS फ़ंक्शन का उपयोग करके रेडियल ग्रेडिएंट को पृष्ठभूमि छवि के रूप में सेट करें। यह फ़ंक्शन एक केंद्र बिंदु से बाहर की ओर फैलने वाला ग्रेडिएंट बनाता है। उदाहरण <!DOCTYPE html> <html> <head> <style> #demo { height: 200px; back