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

CSS में :last-child स्यूडो-क्लास

CSS :last-child स्यूडो-क्लास एक ऐसे एलिमेंट को चुनती है जो किसी अन्य एलिमेंट का अंतिम चाइल्ड एलिमेंट होता है।

सिंटैक्स

निम्नलिखित सिंटैक्स है:

:last-child{    /*declarations*/ }

आइए CSS last-child स्यूडो क्लास का एक उदाहरण देखते हैं:

उदाहरण

<!DOCTYPE html> <html> <head> <style> table {    margin: auto;    padding: 10px;    border: hsl(54, 100%, 50%) solid 13px;    border-radius: 6px;    text-align: center; } td, th {    border-left: 2px solid black;    border-top: 3px solid black; } td:last-child, th:last-child {    border-right: 2px solid black; } th {    background-color: lightblue;    border-top: none; } caption {    margin-top: 3px;    background-color: purple;    caption-side: bottom;    color: white;    border-radius: 20%; } </style> </head> <body> <table> <caption>Demo</caption> <tr> <th colspan="4">Table</th> </tr> <tr> <td>One</td> <td>Two</td> <td>Three</td> <td>Four</td> </tr> <tr> <td>Five</td> <td>Six</td> <td>Seven</td> <td>Eight</td> </tr> </table> </body> </html>

आउटपुट

last-child स्यूडो क्लास सेलेक्टर का उपयोग करने से पहले:

CSS में :last-child स्यूडो-क्लास

last-child स्यूडो क्लास सेलेक्टर का उपयोग करने के बाद:

CSS में :last-child स्यूडो-क्लास

आइए CSS last-child स्यूडो क्लास का एक और उदाहरण देखते हैं:

दूसरा उदाहरण

<!DOCTYPE html> <html> <head> <style> * {    font-size: 1.1em;    list-style: circle; } li:first-child {    background-color: seashell;    font-family: cursive; } li:nth-child(2) {    background-color: azure;    font-family: "Brush Script Std", serif; } li:last-child {    background-color: springgreen;    font-family: "Gigi", Arial; } </style> </head> <body> <h2>What is PHP?</h2> <ul> <li>PHP is a recursive acronym for "PHP: Hypertext Preprocessor".</li> <li>PHP is a server side scripting language that is embedded in HTML. </li> <li>It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server.</li> </ul> </body> </html>

आउटपुट

CSS में :last-child स्यूडो-क्लास

  1. CSS में outline-width प्रॉपर्टी CSS में outline-width प्रॉपर्टी

    outline-width प्रॉपर्टी को एलिमेंट के बॉर्डर्स के चारों ओर एक विशिष्ट मोटाई की लाइन खींचने के लिए परिभाषित किया जा सकता है, लेकिन आउटलाइन बॉर्डर प्रॉपर्टी के विपरीत एलिमेंट के डायमेंशन्स का हिस्सा नहीं होती।सिंटैक्सCSS outline-width प्रॉपर्टी का सिंटैक्स निम्नलिखित है:Selector { outline-width: /*val

  1. CSS में :nth-child Pseudo-class CSS में :nth-child Pseudo-class

    CSS :nth-child() pseudo-class उस एलिमेंट को सिलेक्ट करता है जो किसी अन्य एलिमेंट का nth चाइल्ड एलिमेंट होता है।सिंटैक्सनिम्नलिखित सिंटैक्स है::nth-child(){ /*declarations*/ }उदाहरणआइए CSS :nth-child() Pseudo class का एक उदाहरण देखते हैं:<!DOCTYPE html> <html> <head> <title>CS

  1. CSS में border-color प्रॉपर्टी CSS में border-color प्रॉपर्टी

    CSS border-color प्रॉपर्टी का उपयोग एलिमेंट्स के लिए बॉर्डर कलर स्पेसिफाई करने के लिए किया जाता है। हम border-top-color, border-right-color, border-left-color और border-right-color प्रॉपर्टीज़ का उपयोग करके इंडिविजुअल साइड्स के लिए कलर भी सेट कर सकते हैं।सिंटैक्सCSS border-color प्रॉपर्टी का सिंटैक्