Герб Укріїни
Believe in Ukraine and the Armed Forces. Glory to Ukraine!

Styling for select CSS or How to Style a Dropdown List

26.10.2016

To make your webpage noticeable and stand out against the background, you need to decorate it a bit. Modern software tools offer many ways to do this. CSS3 provides nearly unlimited possibilities for the original design of modern websites. CSS3 allows you to quickly and relatively easily make your site unusual and memorable. In this lesson, I will demonstrate how to change the appearance of a select element (dropdown list) using CSS. You can make it non-standard and impressive.

Let’s consider one of the methods for styling dropdown lists.

2. Method of Styling select CSS

Now I will demonstrate what we can achieve as a result of simple operations:

Style for select CSS or how to style select

Here you can download the source code of Select created with CSS:

 Download, view demo

Let’s take a closer look at the entire process of creating a dropdown list.

Step 1. Connecting Necessary Files

First of all, you need to download the archive with the source materials and take two files from it: style.css and select.js or select_demo2.js. This depends on the type of list you want to create. Include the downloaded files between the <head></head> tags:

Step 2. HTML Structure of the Select Element

Everything is very simple and accessible in HTML markup language. A dropdown list with a number of items.

Step 3. Adding Styles for Select CSS

There aren’t that many styles for select CSS. This material provides styles for the first list. Please remember. There are two paths to the images: one opens (arrow “up”), and the other closes the list (arrow “down”). These paths are also located in the source materials:

In the demonstration version, all styles are located in the css folder. To display the path to the folder, first specify “..” to go up one level, and then enter the images folder.

If we want to create a list with a fixed height, there is no need to copy all the styles, it is enough to insert instead of the dropdownvisible style:

You also need to modify the scripts according to the instructions provided above. As a result, we get:

2016-10-26_125826

In Which Browsers Does This Select CSS (Dropdown List) Work Properly?

  • ✓Firefox 24.0, Firefox 25.0, Firefox 26.0
  • ✓Chrome 29.0, Chrome 30.0, Chrome 31.0
  • ✓Opera 12.14, Opera 12.15, Opera 12.16
  • ✓IE 7.0, IE 8.0, IE 9.0, IE 10.0, IE 11.0
  • ✓Safari 5.1, Safari 6.0, Safari 6.1, Safari 7.0
  • ✓Apple IOS – iPhone 4S, iPhone 5, iPad 2 (5.0), iPad 3 (6.0), iPad Mini
  • ✓Android – Sony Experia X10, HTC One X, Kindle Fire 2, Google Nexus

As you can see, with the help of CSS and Javascript, it is very easy to style the Select dropdown list according to your wishes. Success is guaranteed.

Leave a Reply

Your email address will not be published. Required fields are marked *