search

Home  >  Q&A  >  body text

Custom drop-down arrow

<p>Is it possible to change the dropdown arrow of the select tag to a custom arrow consisting of 4 elements. I want it to look like this: 3 horizontal lines on the left and a downward arrow on the right</p> <p>I successfully achieved this effect with one element (a horizontal line)</p> <pre class="brush:php;toolbar:false;">.select-wrapper::before { content: ""; position: absolute; top: 50%; display: block; width: 9px; height: 2px; background: black; }</pre></p>
P粉986937457P粉986937457505 days ago535

reply all(1)I'll reply

  • P粉633075725

    P粉6330757252023-08-18 14:27:07

    I believe you want to achieve a similar effect to this CodePen. The code comes almost entirely from SVNM's answer to this question

    Modification from this answer

    • Use an image to create the lines/arrows you describe, it might be better if you know how to use SVG
    • Positioning and size of background image

    SampleHTML

    <select name="cars" id="cars">
      <option value="volvo">Volvo</option>
      <option value="saab">Saab</option>
      <option value="mercedes">Mercedes</option>
      <option value="audi">Audi</option>
    </select>

    CSS

    select {
      -webkit-appearance: none;
      -moz-appearance: none;
      background: transparent;
      background-image: url("https://paul7dxb.github.io/hosted-assets/SomePNGs/arrow.png");
      background-repeat: no-repeat;
      background-size: 40px 20px;
      background-position-x: 80%;
      background-position-y: 50%;
      border: 1px solid #dfdfdf;
      border-radius: 2px;
      margin-right: 2rem;
      padding: 1rem;
      padding-right: 2rem;
    }

    reply
    0
  • Cancelreply