Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add padding to the default arrow in a select dropdown list?

Tags:

html-select

I'm trying to follow a design of a select dropdown-list where:

  • Padding: 0 10px 0 10px

However, the arrow is not being adjusted at all. It keeps sticking to the right end. Please see attached screenshot for reference.Front End Screenshot

You can also view my codes here

Is there a way to target the specific arrow and apply paddings to it? (Aiming to keep the same padding applied to the input text for both sides)

Thanks!

like image 535
KvnG. Avatar asked Dec 03 '20 06:12

KvnG.


People also ask

How do I set padding in select options?

For vertical padding you can use line-height. If you don't need border, you can specify border and make it the same color as the select element background, it will give you padding appearance. box-shadow can be used to add stroke to the element if really needed.

How do I remove the default dropdown arrow?

It is this value that we have to alter. Setting this property to “none” will do the job. It explicitly tells the browser to not assign any other value to that property, which in turn results in the removal of the default arrow icon.


1 Answers

I used border-right property and it worked.

select {
  border-right: 16px solid transparent
}

The problem with wrapper element and ":after" is that, it does not toggle the "select" dropdown when you click on the arrow icon.

Working example: https://jsfiddle.net/asaad7/r8sx9m7e/

like image 73
asad makhdoom Avatar answered Nov 02 '22 09:11

asad makhdoom