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

CSS से इमेज पर टेक्स्ट को टॉप-राइट पोजीशन में रखें

CSS में इमेज पर टेक्स्ट को टॉप-राइट (ऊपरी दायां कोना) पोजीशन में रखने के लिए position: absolute के साथ top और right प्रॉपर्टीज का उपयोग किया जाता है। इमेज कंटेनर पर position: relative होना आवश्यक है।

उदाहरण

नीचे दिए गए उदाहरण में, इमेज के ऊपरी दाएं कोने पर "Top Right Corner" टेक्स्ट पोजीशन किया गया है।

<!DOCTYPE html>
<html>
<head>
  <style>
    .box {
      position: relative;
    }
    img {
      width: 100%;
      height: auto;
      opacity: 0.6;
    }
    .direction {
      position: absolute;
      top: 10px;
      right: 19px;
      font-size: 13px;
    }
  </style>
</head>
<body>
  <h1>Heading One</h1>
  <p>Below image has text in the top right:</p>
  <div class="box">
    <img src="https://www.tutorialspoint.com/python/images/python_data_science.jpg" alt="Tutorial" width="800" height="400">
    <div class="direction">Top Right Corner</div>
  </div>
</body>
</html>

मुख्य बिंदु:

  • पैरेंट कंटेनर (.box) पर position: relative
  • चाइल्ड टेक्स्ट (.direction) पर position: absolute
  • top और right से कोने से दूरी
  • z-index से लेयरिंग नियंत्रण (वैकल्पिक)
  1. CSS से इमेज पर बटन कैसे जोड़ें? CSS से इमेज पर बटन कैसे जोड़ें?

    CSS से इमेज पर बटन जोड़ने का कोड निम्नलिखित है:उदाहरण<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> img{    width: 100%; } div {    position: relative;    width

  1. CSS से टेक्स्ट बटन कैसे स्टाइल करें? CSS से टेक्स्ट बटन कैसे स्टाइल करें?

    CSS का उपयोग करके विभिन्न रंगों और शैलियों के टेक्स्ट बटन बनाए जा सकते हैं। इस उदाहरण में पांच अलग-अलग प्रकार के बटन (Success, Info, Warning, Danger, Default) दिखाए गए हैं जिनमें होवर इफेक्ट भी शामिल है। उदाहरण <!DOCTYPE html> <html> <head> <meta name=viewport content=width=

  1. CSS से ग्लोइंग टेक्स्ट कैसे बनाएं? CSS से ग्लोइंग टेक्स्ट कैसे बनाएं?

    CSS से ग्लोइंग टेक्स्ट बनाने के लिए, कोड निम्नानुसार है -उदाहरण<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style>    body {       background-color: rgb(0, 0, 0);