79390219

Date: 2025-01-27 09:21:41
Score: 3
Natty:
Report link

I have the same problem, wanted to make sorting for a table, like in Excel. Turns out setting the width of <select> element to 1rem is just enough for the arrow to appear, but not any text.
Downside is that the selected text will not appear, but this can be changed with JavaScript, or even CSS. Also the arrow won't ben centered, but in these situations you want no border, no background and no padding.

select {
  width: 1rem;
  padding: 0;
  border: none;
  background: transparent;
}
<select>
  <option>Option 1</option>
  <option>Option 2</option>
  <option>Option 3</option>
</select>

Reasons:
  • Blacklisted phrase (1): I have the same problem
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): I have the same problem
  • Low reputation (0.5):
Posted by: Plantt