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

CSS से ब्लैक एंड व्हाइट इमेज कैसे बनाएं?

CSS के फिल्टर प्रॉपर्टी में ग्रेस्केल वैल्यू निर्दिष्ट करके हम ब्लैक एंड व्हाइट इमेज बना सकते हैं। फिल्टर प्रॉपर्टी का उपयोग इमेज पर ब्लर, ड्रॉप-शैडो जैसे स्पेशल इफेक्ट लागू करने के लिए किया जा सकता है।

सिंटैक्स

CSS फिल्टर प्रॉपर्टी का सिंटैक्स निम्नानुसार है:

Selector {    filter: grayscale(100%);    -webkit-filter: grayscale(100%); }

उदाहरण 1

निम्न उदाहरण CSS फिल्टर प्रॉपर्टी को दर्शाते हैं।

<!DOCTYPE html> <html>    <head>       <style>          img {             margin: 2%;             border-radius: 25%;          }          img:nth-of-type(even) {             filter: grayscale(100%);             -webkit-filter: grayscale(100%);          }       </style>    </head>    <body>       <img src="https://images.unsplash.com/photo-1611825715408-826f2b19c43f?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=200&ixlib=rb-1.2.1&q=80&w=200" alt="img from unsplash">       <img src="https://images.unsplash.com/photo-1611825715408-826f2b19c43f?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=200&ixlib=rb-1.2.1&q=80&w=200" alt="img from unsplash">    </body> </html>

इससे निम्न आउटपुट मिलता है:

CSS से ब्लैक एंड व्हाइट इमेज कैसे बनाएं?

उदाहरण 2 (ऑड इमेज पर)

<!DOCTYPE html> <html>    <head>       <style>          img {             margin: 2%;          }          img:nth-of-type(odd) {             filter: grayscale(100%);             -webkit-filter: grayscale(100%);          }       </style>    </head>    <body>       <img src="https://images.unsplash.com/photo-1611781750917-8777ab68668a?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=256&ixlib=rb-1.2.1&q=80&w=256">       <img src="https://images.unsplash.com/photo-1611781750917-8777ab68668a?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=256&ixlib=rb-1.2.1&q=80&w=256">    </body> </html>

इससे निम्न आउटपुट मिलता है:

CSS से ब्लैक एंड व्हाइट इमेज कैसे बनाएं?

  1. CSS से ब्लरी बैकग्राउंड इमेज कैसे बनाएं? CSS से ब्लरी बैकग्राउंड इमेज कैसे बनाएं?

    CSS से ब्लरी बैकग्राउंड इमेज बनाने का कोड निम्नलिखित है:उदाहरण<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style> body, html {    height: 100vh;    margin: 0;    f

  1. CSS से स्टिकी इमेज कैसे बनाएं? CSS से स्टिकी इमेज कैसे बनाएं?

    CSS से स्टिकी इमेज बनाने का कोड निम्नलिखित है:उदाहरण<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> img {    position: sticky;    top: 0;    width: 300px;  

  1. CSS clip-path से ट्रायंगल कैसे बनाएं? CSS clip-path से ट्रायंगल कैसे बनाएं?

    हम CSS clip-path प्रॉपर्टी का उपयोग करके एक ट्रायंगल बना सकते हैं। सिंटैक्स CSS clip-path प्रॉपर्टी का सिंटैक्स निम्नानुसार है: Selector {    clip-path: /*value*/ } उदाहरण 1 निम्न उदाहरण CSS clip-path प्रॉपर्टी को दर्शाते हैं। <!DOCTYPE html> <html>    <head> &n