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

CSS में ::first-line स्यूडो-एलिमेंट

CSS का ::first-line स्यूडो-एलिमेंट किसी एलिमेंट की सामग्री की पहली लाइन को चुनता है। हालांकि, यदि टेक्स्ट वाले कंटेनर की चौड़ाई निश्चित नहीं है, तो लाइन की लंबाई विंडो के आकार के अनुसार बदल सकती है।

उदाहरण

आइए CSS ::first-line स्यूडो-एलिमेंट का एक उदाहरण देखें:

<!DOCTYPE html> <html> <head> <style> p::first-line {    background-color: lightgreen;    color: white; } </style> </head> <body> <h2>Lorem Ipsum</h2> <p>Phasellus id ante turpis.Vestibulum luctus justo id odio iaculis condimentum. Vestibulum sapien mauris, feugiat id posuere vitae, condimentum blandit sapien.</p> <div id="divDisplay"></div> <script> divDisplay.textContent = 'Current window width: '+window.innerWidth+'px'; window.addEventListener('resize', function() {    divDisplay.textContent = 'Current window width: '+window.innerWidth+'px'; }) </script> </body> </html>

आउटपुट

प्रारंभ में जब विंडो की चौड़ाई '606px' हो:

CSS में ::first-line स्यूडो-एलिमेंट

जब विंडो की चौड़ाई बढ़ाई जाती है:

CSS में ::first-line स्यूडो-एलिमेंट

जब टेक्स्ट वाले एलिमेंट की चौड़ाई निश्चित हो और विंडो का आकार बदला जाए:

CSS में ::first-line स्यूडो-एलिमेंट

एक और उदाहरण

आइए CSS ::first-line स्यूडो-एलिमेंट का एक और उदाहरण देखें:

<!DOCTYPE html> <html> <head> <style> p::first-line {    background-color: #FF8A00;    color: white; } div{    width: 420px; } </style> </head> <body> <div> <h2>Demo Heading</h2> <p>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. </p> <p>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. This is demo text. This is demo text. </p> </div> </body> </html>

आउटपुट

CSS में ::first-line स्यूडो-एलिमेंट

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

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

  1. CSS में @media At-rules CSS में @media At-rules

    CSS @media नियम का उपयोग एक ही स्टाइल शीट में विभिन्न मीडिया टाइप्स (जैसे print, screen, all, आदि) के लिए अलग-अलग स्टाइल्स स्पेसिफाई करने के लिए किया जाता है। यह आमतौर पर मीडिया टाइप्स की कॉमा-सेपरेटेड लिस्ट और CSS डिक्लेरेशन ब्लॉक द्वारा फॉलो किया जाता है जिसमें टारगेट मीडिया के लिए स्टाइल नियम होत

  1. CSS में ::first-letter Pseudo-element CSS में ::first-letter Pseudo-element

    यह CSS Pseudo Element किसी एलिमेंट के कंटेंट के पहले अक्षर को सिलेक्ट करता है। हालांकि, यह काम नहीं करता यदि एलिमेंट इनलाइन-लेवल है।उदाहरणआइए CSS ::first-letter pseudo element के लिए एक उदाहरण देखते हैं:<!DOCTYPE html> <html> <head> <style> div{ background-color: #32485d; bor