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

CSS से बटन ग्रुप बनाएं - हॉरिजॉन्टल

हॉरिजॉन्टल (क्षैतिज) बटन ग्रुप बनाने के लिए बटन्स को एक कंटेनर में रखें और display: flex या float: left (पुराना तरीका) का उपयोग करें। मॉडर्न दृष्टिकोण Flexbox का उपयोग करता है।

उदाहरण: फ्लेक्सबॉक्स से हॉरिजॉन्टल बटन ग्रुप

<!DOCTYPE html>
<html>
<head>
  <style>
    .btn-group {
      display: flex;
      gap: 0;  /* बटन्स के बीच कोई गैप नहीं */
      border: 1px solid #ccc;
      border-radius: 4px;
      overflow: hidden;
    }
    .btn-group button {
      flex: 1;
      color: black;
      background-color: orange;
      border: none;
      border-right: 1px solid #ccc;
      text-align: center;
      font-size: 15px;
      padding: 12px 20px;
      cursor: pointer;
      transition: background-color 0.2s;
    }
    .btn-group button:last-child {
      border-right: none;
    }
    .btn-group button:hover {
      background-color: darkorange;
    }
    .btn-group button:active {
      background-color: #cc7700;
    }
  </style>
</head>
<body>
  <h2>परिणाम</h2>
  <p>नीचे क्लिक करें:</p>
  <div class="btn-group">
    <button class="btn">रिज़ल्ट 1</button>
    <button class="btn">रिज़ल्ट 2</button>
    <button class="btn">रिज़ल्ट 3</button>
    <button class="btn">रिज़ल्ट 4</button>
    <button class="btn">रिज़ल्ट 5</button>
  </div>
</body>
</html>

पुराना तरीका (float) - टालें

/* पुराना तरीका - मॉडर्न प्रोजेक्ट्स में उपयोग न करें */
.btn { float: left; }
.btn-group::after { content: ""; display: table; clear: both; }

वैरिएशन: आउटलाइन बटन ग्रुप

.btn-group-outline button {
  background: transparent;
  border: 1px solid orange;
  color: orange;
}
.btn-group-outline button:hover {
  background: orange;
  color: white;
}

वैरिएशन: मिश्रित बटन ग्रुप

.btn-group .btn-primary { background: #007bff; color: white; }
.btn-group .btn-secondary { background: #6c757d; color: white; }
.btn-group .btn-danger { background: #dc3545; color: white; }
  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 से बेसिक कार्ड कैसे बनाएं?

    बेसिक कार्ड में इमेज, नाम, पदनाम होता है। बॉक्स-शैडो, होवर पर शैडो गहरी, पदनाम बैज स्टाइल, रिस्पॉन्सिव चौड़ाई (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