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

CSS से इमेज ओवरले होवर इफेक्ट कैसे बनाएं?


CSS से इमेज ओवरले होवर इफेक्ट बनाने का कोड निम्नलिखित है:

उदाहरण

<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> .card-container {    display: inline-block;    position: relative;    width: 50%; } img {    opacity: 1;    display: block;    width: 100%;    transition: .5s ease;    backface-visibility: hidden; } .hoverText {    transition: .5s ease;    opacity: 0;    position: absolute;    top: 50%;    left: 40%;    text-align: center; } .card-container:hover img {    opacity: 0.4; } .card-container:hover .hoverText {    opacity: 1; } .caption {    background-color: rgb(18, 53, 131);    color: white;    font-size: 30px;    padding: 20px;    border-radius: 6px;    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;    font-weight: bolder; } </style> </head> <body> <h1>Image Overlay effect Example</h1> <div class="card-container"> <img src="https://i.picsum.photos/id/237/536/354.jpg"> <div class="hoverText"> <div class="caption">Dog</div> </div> </div> </body> </html>

आउटपुट

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

CSS से इमेज ओवरले होवर इफेक्ट कैसे बनाएं?

इमेज पर होवर करने पर कैप्शन निम्नानुसार दिखाया जाएगा:

CSS से इमेज ओवरले होवर इफेक्ट कैसे बनाएं?


  1. CSS से ओवरले इफेक्ट (मोडल/पॉपअप) कैसे बनाएं? CSS से ओवरले इफेक्ट (मोडल/पॉपअप) कैसे बनाएं?

    ओवरले पूरे व्यूपोर्ट को कवर करता है (position: fixed; top: 0; left: 0; width/height: 100%)। डिफ़ॉल्ट display: none, बटन क्लिक पर JS से display: block। rgba बैकग्राउंड से पेज डिम होता है। सर्च बार और क्लोज बटन शामिल। उदाहरण <!DOCTYPE html> <html> <head> <link rel=stylesheet h

  1. CSS से स्मूथ स्क्रॉलिंग प्रभाव कैसे बनाएं? CSS से स्मूथ स्क्रॉलिंग प्रभाव कैसे बनाएं?

    CSS से स्मूथ स्क्रॉलिंग प्रभाव बनाने के लिए, कोड निम्नानुसार है -उदाहरण<!DOCTYPE html> <html> <head> <style>    html {       scroll-behavior: smooth;    }    * {       box-sizing: border-box;    }   &n

  1. CSS से पैरालैक्स स्क्रोलिंग प्रभाव कैसे बनाएं? CSS से पैरालैक्स स्क्रोलिंग प्रभाव कैसे बनाएं?

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