banner



How To Change Background Color Of Select2

In this tutorial, learn how to style a select dropdown box in CSS. The short answer is to use the 'appearance: none' CSS belongings that removes the overall default style including the pointer.

You can also employ the CSS property 'overflow: hidden' to change the arrow of the select dropdown box. Allow's find out the different methods to style the select box with the examples given below.

How to Style a Select Dropdown Box in CSS

You can change the background, font size, the color of text, add borders, and other properties to style the select dropdown box using CSS properties. It'southward easier to style CSS every bit given in the example below.

Exam it Alive

Output

How to Style a Select Dropdown Box Using CSS Only

The above example shows the added background, the color of the text, and the font size of the select box.

However, yous cannot modify the default with these CSS properties. Permit's find out the below methods to change the default pointer of the select box.

Modify Select Dropdown Pointer Using 'appearance: none' in CSS

The default select box contains an arrow that shows the dropdown in a course. However, you can change the select dropdown arrow using the CSS property 'advent: none'. It removes the overall style of the select box. After that, yous tin add together your style to the select box as per your requirements.

Yous can add font crawly icons in identify of the select box arrow. After that, you lot can modify the color and font size of the font awesome icon to friction match it with your select dropdown box.

Test information technology Alive

Output

Change Select Dropdown Arrow Using 'appearance: none' in CSS

The above output shows the changes dropdown arrow and the added font awesome icon to information technology.

Add Epitome In Place of Arrow Using 'overflow: hidden' in CSS

In addition to the above methods, you can also add the background prototype in place of the select dropdown arrow using CSS. To add together the prototype in place of the arrow, y'all accept to employ the CSS property 'overflow: hidden'.

You have to first place the select box within the <div>. Later on that, add together width to the select box and width to the parent chemical element 20px less than the select box. Also, add together CSS property 'overflow: hidden' to the div element.

Now, you can add the background epitome in place of the select box arrow. Come across the instance given below to learn the method.

Test it Live

Output

Add Image In Place of Arrow Using 'overflow: hidden' in CSS

The above examples show the select box with added background image in place of the dropdown pointer. You tin add any background epitome of your choice equally per your requirements.

You May Also Similar to Read

  • How to Open Dropdown on Hover Using jQuery and JS
  • Evidence/Hide Div On Dropdown Selected Using jQuery
  • How to Show Bootstrap Dropdown Card on Hover
  • Change Image On Dropdown Select Option Using jQuery

Source: https://tutorialdeep.com/knowhow/style-select-dropdown-css/

Posted by: peaseandided.blogspot.com

0 Response to "How To Change Background Color Of Select2"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel