Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> 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: 100%;    max-width: 400px; } div img {    width: 100%;    height: auto; } div button {    position: absolute;    top: 50%;    left: 50%;    transform: translate(-50%, -50%);    background-color: rgb(64, 21, 133);    color: white;    font-size: 20px;    padding: 24px 36px;    width: 220px;    border: none;    cursor: pointer;    border-radius: 5px;    text-align: center;    font-weight: bolder;    font-family: monospace,sans-serif,serif; } div button:hover {    color:yellow; } </style> </head> <body> <h1>Button on Image Example</h1> <div> <img src="https://i.picsum.photos/id/354/400/400.jpg"> <button class="btn">Button</button> </div> </body> </html>

आउटपुट

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

CSS से इमेज पर बटन कैसे जोड़ें?

बटन पर होवर करने पर बटन का रंग बदलेगा जैसा दिखाया गया है:

CSS से इमेज पर बटन कैसे जोड़ें?


  1. CSS से इमेज पर बॉर्डर कैसे जोड़ें? CSS से इमेज पर बॉर्डर कैसे जोड़ें?

    CSS से इमेज पर बॉर्डर जोड़ने का कोड निम्नलिखित है:उदाहरण<!DOCTYPE html> <html> <head> <style> img {    border: 8px solid rgb(0, 238, 255);    width: 400px;    height: 400px; } </style> </head> <body> <h1>Border Around Imag

  1. CSS से सर्च बटन (आइकन के साथ) कैसे बनाएं? CSS से सर्च बटन (आइकन के साथ) कैसे बनाएं?

    सर्च बटन में इनपुट फील्ड और सबमिट बटन साथ-साथ होते हैं। बटन में Font Awesome सर्च आइकन होता है। फ्लोट लेआउट से 80/20 चौड़ाई विभाजन, नीला बटन, होवर पर गहरा नीला। उदाहरण <!DOCTYPE html> <html> <head> <meta name=viewport content=width=device-width, initial-scale=1> <lin

  1. CSS से होवर पर ट्रांज़िशन कैसे जोड़ें? CSS से होवर पर ट्रांज़िशन कैसे जोड़ें?

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