Back to CSS Input Fields Time Range Pure CSS
Share
HTML
<fieldset class="if-time">
  <legend class="if-time-legend">Quiet hours</legend>
  <span class="if-time-row">
    <label
      ><span class="if-time-cap">From</span><input type="time" name="from" value="22:00"
    /></label>
    <span class="if-time-sep" aria-hidden="true">→</span>
    <label><span class="if-time-cap">To</span><input type="time" name="to" value="07:00" /></label>
  </span>
</fieldset>
CSS
.if-time {
  width: 100%;
  max-width: 320px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 14px;
  background: #1a1a22;
}

.if-time-legend {
  padding: 0 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #b8b6d4;
  text-transform: uppercase;
}

.if-time-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.if-time label {
  flex: 1;
  display: grid;
  gap: 4px;
}

.if-time-cap {
  font-size: 10px;
  color: #b8b6d4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.if-time input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  background: #0c0c12;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #f0eeff;
  font:
    600 13px/1 "JetBrains Mono",
    monospace;
  outline: none;
  color-scheme: dark;
}

.if-time input:focus {
  border-color: #a78bfa;
}

.if-time-sep {
  color: #a78bfa;
  font-size: 14px;
  align-self: end;
  padding-bottom: 9px;
}