Custom drop-down arrow
P粉986937457
P粉986937457 2023-08-17 17:52:04
0
1
492
<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粉986937457
P粉986937457

reply all(1)
P粉633075725

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;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!