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

CSS var() फ़ंक्शन का उपयोग

CSS var() फ़ंक्शन कस्टम प्रॉपर्टी (CSS वेरिएबल) के मान को डालने के लिए उपयोग किया जाता है। :root में कस्टम प्रॉपर्टी परिभाषित करें और फिर var(--name) से उपयोग करें।

उदाहरण

<!DOCTYPE html> <html>    <head>       <style>          :root {             --my-bg-color: blue;             --my-color: white;          }          #demo {             background-color: var(--my-bg-color);             color: var(--my-color);          }       </style>    </head>    <body>       <h1>Heading One</h1>       <div id = "demo">          This is demo text. This is demo text. This is demo text.          This is demo text. This is demo text. This is demo text.          This is demo text. This is demo text. This is demo text.          </div>       <br>    </body> </html>

व्याख्या: :root में --my-bg-color और --my-color परिभाषित हैं। #demo में var() से उनका उपयोग किया गया है, जिससे थीम बदलना आसान हो जाता है।

  1. CSS linear-gradient() फंक्शन CSS linear-gradient() फंक्शन

    linear-gradient() फंक्शन linear-gradient() का उपयोग रैखिक ग्रेडिएंट को बैकग्राउंड इमेज के रूप में परिभाषित करने के लिए किया जाता है। सिंटैक्स: background-image: linear-gradient(direction, color-stop1, color-stop2, ...); पैरामीटर्स: direction: ग्रेडिएंट की दिशा (to right, to bottom right, 45deg

  1. CSS right प्रॉपर्टी CSS right प्रॉपर्टी

    right प्रॉपर्टी right प्रॉपर्टी का उपयोग एलिमेंट की क्षैतिज स्थिति सेट करने के लिए किया जाता है। यह पोजिशन्ड एलिमेंट्स (relative, absolute, fixed, sticky) पर काम करता है। सिंटैक्स: right: auto | length | % | initial | inherit; मान: auto: ब्राउज़र गणना करता है (डिफ़ॉल्ट) length: px, em, rem,

  1. CSS से टेक्स्ट इंडेंटेशन CSS से टेक्स्ट इंडेंटेशन

    text-indent प्रॉपर्टी टेक्स्ट इंडेंटेशन के लिए CSS में text-indent प्रॉपर्टी का उपयोग करें। यह पैराग्राफ की पहली लाइन की इंडेंटेशन के लिए है। उदाहरण 1: 30px इंडेंट <!DOCTYPE html> <html> <head> <style> div { text-indent: 30px; } </style> </head> <body> <