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

CSS से आइकन बटन कैसे बनाएं?


आइकन बटन टेक्स्ट के साथ Font Awesome आइकन जोड़कर उपयोगकर्ता अनुभव को बेहतर बनाते हैं। इस उदाहरण में होवर पर आइकन और बटन दोनों का रंग बदलता है।

उदाहरण

<!DOCTYPE html>
<html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
  <style>
    button {
      font-family: "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif;
      background-color: rgb(30, 173, 255);
      border: none;
      color: white;
      padding: 12px 16px;
      font-size: 32px;
      cursor: pointer;
    }
    i {
      padding: 15px;
      color: rgb(33, 0, 109);
    }
    button:hover {
      background-color: rgb(81, 44, 148);
    }
    button:hover i {
      color: white;
    }
  </style>
</head>
<body>
  <h1 style="font-size: 60px; font-family: Arial, Helvetica, sans-serif;">Icon Buttons Example</h1>
  <button><i class="fa fa-home"></i>Home</button>
  <button><i class="fa fa-phone-square" aria-hidden="true"></i>Call Us</button>
  <button><i class="fa fa-map-marker" aria-hidden="true"></i>Visit Us</button>
  <button><i class="fa fa-cog" aria-hidden="true"></i>Settings</button>
  <button><i class="fa fa-user-o" aria-hidden="true"></i>Login</button>
</body>
</html>

आउटपुट

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

CSS से आइकन बटन कैसे बनाएं?

आइकन बटन पर होवर करने पर:

CSS से आइकन बटन कैसे बनाएं?

मुख्य बिंदु

  • Font Awesome CDN - आइकन लाइब्रेरी शामिल करने के लिए
  • i टैग स्टाइलिंग - आइकन के लिए अलग पैडिंग और रंग
  • होवर पर रंग परिवर्तन - बटन और आइकन दोनों के लिए
  • aria-hidden="true" - स्क्रीन रीडर के लिए आइकन छुपाता है
  • सिमेंटिक HTML - बटन तत्व का उचित उपयोग
  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 {       margin: 0 auto;       max-widt

  1. CSS से सेक्शन काउंटर कैसे बनाएं? CSS से सेक्शन काउंटर कैसे बनाएं?

    उदाहरण CSS से सेक्शन काउंटर बनाने के लिए, निम्न कोड का उपयोग करें: <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font