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

CSS से टूलटिप कैसे बनाएं (एडवांस वर्जन)?


एडवांस टूलटिप में फेड-इन एनिमेशन (opacity + transition), तीर (::after बॉर्डर ट्रिक), केंद्रित संरेखण (left: 50%; margin-left: -60px), और पैरेंट के ऊपर स्थित होता है।

उदाहरण

<!DOCTYPE html>
<html>
<style>
  body { text-align: center; font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; }
  .tooltip {
    position: relative; display: inline-block;
    border-bottom: 1px dotted black; font-size: 20px;
    font-weight: bolder; color: blue;
  }
  .tooltip .toolText {
    visibility: hidden; width: 120px;
    background-color: rgb(89, 166, 255); color: #fff;
    text-align: center; border-radius: 6px; padding: 10px 20px;
    font-weight: normal; position: absolute; z-index: 1;
    bottom: 125%; left: 50%; margin-left: -60px;
    opacity: 0; transition: opacity 0.3s;
  }
  .tooltip .toolText::after {
    content: ""; position: absolute; top: 100%; left: 50%;
    margin-left: -5px; border-width: 5px; border-style: solid;
    border-color: #555 transparent transparent transparent;
  }
  .tooltip:hover .toolText { visibility: visible; opacity: 1; }
</style>
<body>
  <h1>Tooltip Example</h1>
  <div class="tooltip"> Hover Here <span class="toolText">Some Random Text</span> </div>
  <p>Hover over the above text to see tooltip in action</p>
</body>
</html>

आउटपुट

उपरोक्त कोड निम्नलिखित आउटपुट उत्पन्न करेगा:

CSS से टूलटिप कैसे बनाएं (एडवांस वर्जन)?

"Hover Here" टेक्स्ट पर होवर करने पर:

CSS से टूलटिप कैसे बनाएं (एडवांस वर्जन)?

मुख्य बिंदु

  • opacity ट्रांजिशन - 0.3s फेड-इन/आउट
  • केंद्रित संरेखण - left: 50%, margin-left: -width/2
  • CSS त्रिकोण - ::after बॉर्डर से नीचे तीर
  • bottom: 125% - पैरेंट के ऊपर गैप के साथ
  • डॉटेड अंडरलाइन - टूलटिप ट्रिगर संकेत
  • z-index - अन्य कंटेंट के ऊपर
  1. CSS से बेसिक कार्ड कैसे बनाएं? CSS से बेसिक कार्ड कैसे बनाएं?

    बेसिक कार्ड में इमेज, नाम, पदनाम होता है। बॉक्स-शैडो, होवर पर शैडो गहरी, पदनाम बैज स्टाइल, रिस्पॉन्सिव चौड़ाई (40%, मैक्स 300px)। उदाहरण <!DOCTYPE html> <html> <head> <meta name=viewport content=width=device-width, initial-scale=1> <style> body { font-family:

  1. CSS से कूपन बनाना CSS से कूपन बनाना

    कूपन डिज़ाइन CSS से कूपन बनाने के लिए निम्न कोड उपयोग करें: उदाहरण <!DOCTYPE html> <html> <head> <meta name=viewport content=width=device-width, initial-scale=1 /> <style> body { font-family: Segoe UI, Tahoma, Geneva, Verdana, sans-serif; } img { width: 100%; } .coupon

  1. CSS से तीर कैसे बनाएं? CSS से तीर कैसे बनाएं?

    CSS से तीर बनाने के लिए, कोड निम्नानुसार है -उदाहरण<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style>    body {       font-family: "Segoe UI", Tahoma, Geneva