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

फॉर्म इनपुट फील्ड्स के लिए कुछ कम-ज्ञात CSS प्रॉपर्टीज


परिचय

CSS caret-color, pointer-events, और tab-size फॉर्म इनपुट फील्ड्स के लिए कुछ कम-ज्ञात प्रॉपर्टीज हैं। caret-color हमें ब्लिंकिंग कैरेट का रंग निर्दिष्ट करने की अनुमति देता है, pointer-events उपयोगकर्ताओं को किसी एलिमेंट के साथ इंटरैक्ट करने से रोकने में मदद कर सकता है, और tab-size टैब द्वारा उपयोग किए जाने वाले व्हाइट स्पेस की मात्रा सेट करता है।

उदाहरण 1: टैब साइज और पॉइंटर इवेंट्स

<!DOCTYPE html>
<html>
<head>
  <style>
    body {
      display: flex;
      flex-direction: column;
      background-color: mistyrose;
    }
    p {
      white-space: pre;
    }
    p:last-of-type {
      tab-size: 32;
      -moz-tab-size: 32;
      pointer-events: none;
    }
  </style>
</head>
<body>
  <p> Ut sed felis lobortis, fermentum magna vitae, imperdiet lectus.</p>
  <p> Ut sed felis lobortis, <a href="#">fermentum magna vitae</a>, imperdiet lectus.</p>
</body>
</html>

उदाहरण 2: कैरेट कलर के साथ फॉर्म

<!DOCTYPE html>
<html>
<head>
  <style>
    form {
      padding: 2%;
      margin: 3%;
      background-color: cadetblue;
      text-align: center;
    }
    form:focus-within {
      box-shadow: 0 0 10px rgba(0,0,0,0.6);
    }
    input {
      caret-color: navy;
      font-size: 40px;
      font-weight: large;
    }
  </style>
</head>
<body>
  <form>
    <select>
      <option>.</option>
      <option>..</option>
      <option>...</option>
    </select>
    <input type="text" value="glee" />
  </form>
</body>
</html>

अन्य उपयोगी फॉर्म-संबंधित CSS प्रॉपर्टीज

प्रॉपर्टी विवरण उदाहरण
accent-color फॉर्म कंट्रोल्स (चेकबॉक्स, रेडियो, रेंज) का एक्सेंट रंग सेट करता है input { accent-color: #0066cc; }
field-sizing कंटेंट के आधार पर इनपुट आकार को नियंत्रित करता है input { field-sizing: content; }
caret-shape कैरेट आकार सेट करता है (प्रायोगिक) input { caret-shape: block; }
input-security सुरक्षित इनपुट मोड (प्रायोगिक) input { input-security: auto; }

व्यावहारिक उदाहरण: मॉडर्न फॉर्म स्टाइलिंग

<!DOCTYPE html>
<html lang="hi">
<head>
  <style>
    .modern-form {
      max-width: 400px;
      margin: 2rem auto;
      padding: 2rem;
      background: white;
      border-radius: 12px;
      box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    }
    .form-group { margin-bottom: 1.5rem; }
    .form-group label {
      display: block;
      margin-bottom: 0.5rem;
      font-weight: 500;
      color: #374151;
    }
    .form-group input,
    .form-group select,
    .form-group textarea {
      width: 100%;
      padding: 0.75rem 1rem;
      border: 2px solid #e5e7eb;
      border-radius: 8px;
      font-size: 1rem;
      font-family: inherit;
      transition: border-color 0.2s, box-shadow 0.2s;
      caret-color: #3b82f6; /* ब्रांडेड कैरेट */
      accent-color: #3b82f6; /* चेकबॉक्स/रेडियो के लिए */
    }
    .form-group input:focus,
    .form-group select:focus,
    .form-group textarea:focus {
      outline: none;
      border-color: #3b82f6;
      box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
    }
    .form-group input::placeholder {
      color: #9ca3af;
    }
    .form-group textarea {
      min-height: 120px;
      resize: vertical;
      field-sizing: content; /* मॉडर्न ऑटो-रिसाइज */
    }
  </style>
</head>
<body>
  <form class="modern-form">
    <h2 style="margin-bottom: 1.5rem;">संपर्क फ़ॉर्म</h2>
    <div class="form-group">
      <label for="name">नाम</label>
      <input type="text" id="name" placeholder="आपका नाम" required />
    </div>
    <div class="form-group">
      <label for="email">ईमेल</label>
      <input type="email" id="email" placeholder="you@example.com" required />
    </div>
    <div class="form-group">
      <label>प्राथमिकताएं</label>
      <label style="display:flex; align-items:center; gap:0.5rem; margin:0.5rem 0; font-weight:400;">
        <input type="checkbox" checked /> न्यूज़लेटर
      </label>
      <label style="display:flex; align-items:center; gap:0.5rem; margin:0.5rem 0; font-weight:400;">
        <input type="checkbox" /> अपडेट्स
      </label>
    </div>
    <button type="submit" style="width:100%; padding:1rem; background:#3b82f6; color:white; border:none; border-radius:8px; font-size:1rem; font-weight:600; cursor:pointer;">सबमिट करें</button>
  </form>
</body>
</html>
  1. CSS से टेक्स्टबॉक्स में प्लेसहोल्डर कलर कैसे बदलें? CSS से टेक्स्टबॉक्स में प्लेसहोल्डर कलर कैसे बदलें?

    ::placeholder प्सूडो-एलिमेंट का उपयोग करके, हम टेक्स्टबॉक्स के लिए प्लेसहोल्डर टेक्स्ट कलर बदल सकते हैं। CSS ::placeholder प्सूडो-एलिमेंट का सिंटैक्स निम्नानुसार है: ::placeholder { attribute: /*value*/ } उदाहरण 1 निम्न उदाहरण CSS :: placeholder प्सूडो-एलिमेंट को दर्शाते हैं। <!DOCTYPE html> &

  1. 2020 में वेब डिज़ाइन के लिए नवीनतम CSS प्रॉपर्टीज़ और APIs 2020 में वेब डिज़ाइन के लिए नवीनतम CSS प्रॉपर्टीज़ और APIs

    नई CSS प्रॉपर्टीज़ और APIs डेवलपर्स को JavaScript और CSS के मिश्रण से वेबसाइट कस्टमाइज़ करने में मदद के लिए नई CSS प्रॉपर्टीज़ विकसित की गई हैं जो अब लोकप्रिय ब्राउज़र्स में सपोर्टेड हैं। कुछ नीचे सूचीबद्ध हैं: focus-within एलिमेंट्स के भीतर फोकस-एक्सेसिबिलिटी को हल करने का लक्ष्य। scroll-snap नेटि

  1. CSS अपडेट: टेक्स्ट डेकोरेशन और अंडरलाइन स्टाइलिंग के लिए नए प्रॉपर्टीज CSS अपडेट: टेक्स्ट डेकोरेशन और अंडरलाइन स्टाइलिंग के लिए नए प्रॉपर्टीज

    परिचय नए टेक्स्ट-डेकोरेशन प्रॉपर्टीज की शुरुआत के साथ, हम पहले से कहीं अधिक तरीकों से टेक्स्ट को स्टाइल कर सकते हैं। text-decoration अब text-decoration-thickness, text-decoration-color, text-decoration-line, और text-decoration-style के लिए शॉर्टहैंड है। text-decoration-skip, text-decoration-skip-in