Is it possible to customize my selectbox by adding a logo to each item in the dropdown menu?

Looking to customize my select box with app logos next to the options. Any suggestions or tips would be greatly appreciated! ❤️

<select class="selectdiv2" id="selection2" name="platform" required>
  <option value="">-- please select a platform --</option>
  <option value="WhatsApp">WhatsApp</option>
  <option value="Instagram">Instagram</option>
</select>

Answer №1

I stumbled upon a neat HTML/CSS solution that doesn't require JavaScript knowledge like other solutions.

.dropbtn {
            background-color: #4CAF50;
            color: white;
            padding: 16px;
            font-size: 16px;
            border: none;
            cursor: pointer;
        }
  
        .dropdown {
            position: relative;
            display: inline-block;
        }
  
        .dropdown-content {
            display: none;
            position: absolute;
            background-color: #f9f9f9;
            min-width: 160px;
            box-shadow: 0px 8px 16px 
                0px rgba(0, 0, 0, 0.2);
            z-index: 1;
        }
  
        .dropdown-content a {
            color: black;
            padding: 12px 16px;
            text-decoration: none;
            display: block;
        }
  
        .dropdown-content a:hover {
            background-color: #f1f1f1
        }
  
        .dropdown:hover .dropdown-content {
            display: block;
        }
  
        .dropdown:hover .dropbtn {
            background-color: #3e8e41;
        }
 <div class="dropdown">
            <button class="dropbtn">
                Country Flags
            </button>
              
            <div class="dropdown-content">
                <a href="#">
                    <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200630132503/iflag.jpg"
                    width="20" height="15"> India</a>
  
                <a href="#">
                    <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200630132504/uflag.jpg"
                    width="20" height="15"> USA</a>
                <a href="#">
                    <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200630132502/eflag.jpg"
                    width="20" height="15"> England</a>
                <a href="#">
                    <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200630132500/bflag.jpg"
                    width="20" height="15"> Brazil<a/a>
            </div>
        </div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Display a magnified version of a thumbnail image using jQuery

I am currently working on enhancing my JQuery code to display a larger version of the thumbnail image. Here is the code I have so far, which only shows the thumbnail in its original size: $(".gallerythumbnail").click(function() { $(".showimagelightdow ...

css three columns evenly spaced in the center

I am currently using bootstrap, CSS, and HTML to design a responsive webpage with three columns in a row. The layout consists of a textbox on the left, a button in the center, and a table on the right. So far, I have made three separate attempts at achiev ...

Tips for adjusting the size of an SVG using percentages

I have multiple tables with data in them, each sized using percentage and resizable. I want to add SVG images to each table without affecting the table size. When I tried setting the sizing like this: <svg xmlns="http://www.w3.org/2000/svg" xml:space=" ...

The font of the <select> element is currently set to MS Shell Dlg by default

The tools I am currently utilizing are as follows: body { font-family: Verdana, Arial, Helvetica, sans-serif; background: url(/Content/images/bg.png) no-repeat center top; min-height: 100%; } Although I do not explicitly style my select boxes ...

Tips on swapping out an image multiple times as you hover over various text options

As a Designer creating a portfolio website, I have a good understanding of HTML and CSS. Here is my homepage: https://i.sstatic.net/WWMPA.png I am looking to create a feature where different images are displayed in a red circle preview when hovering over ...

The word-breaking function is not functioning as anticipated

I am facing an issue with a container that holds multiple divs. I am attempting to prevent the contents of these divs from overflowing their parent element and breaking the text if it exceeds the parent's boundaries. However, my efforts are unsuccessf ...

The Bootstrap dropdown menu fails to display properly within the "col" element

Here is the HTML code I am working with: <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-t ...

Struggling to make bootstraps' responsiveness function properly

I've been struggling to achieve responsiveness on a webpage I'm working on, but despite trying different approaches including wrapping the table as suggested in another forum post, I still can't get it to work. Could someone please help me i ...

Twitter-Bootstrap: implementing text underlines for thumbnail captions

While experimenting with Bootstrap, I aimed to create a layout similar to ; a grid featuring bordered panels containing text and images. After some research, I concluded that Bootstrap's Thumbnail component would be the most suitable choice for my pro ...

Text fields do not show a cursor icon

On the website http://www.legrandclub.net, there are two text fields. Everything works fine in all web browsers except for Internet Explorer. When I click on one of the text fields, the cursor is not displayed, although it is possible to write text. What c ...

Is the zero-height navigation bar still apparent on the screen?

I am currently working on a portfolio website and I have a specific idea in mind for how I want the work to be displayed. I would like it to slide up onto the screen when the user clicks on the portfolio section, similar to how a navigation bar slides over ...

Design Shapes in Sketch with CSS Styling

Here is the CSS code I am working with: shadowColor: '#444', shadowOffset: { width: 5, height: 5 }, shadowOpacity: 0.2, shadowRadius: 8, backgroundColor: 'white', borderRadius: 10, I want to recreate this style in Sketch, but it uses ...

transforming a text input into unadorned plain text

Currently, I am in the process of creating a small HTML form that consists of a single textbox input. Once the user enters text into this textbox and clicks on a button located at the end of the page, I would like the textbox to transform into normal plain ...

Designing personalized sass components

Seeking advice on developing a custom CSS unit that can be utilized in Sass with Node.js. Is there a tutorial available for creating a Sass plugin specifically for this purpose? For instance, I am looking to establish a unit called "dpx" which functions as ...

Displaying checkbox values with JavaScript

How can I display multiple checkbox values when checked in HTML code? Whenever I check a checkbox, I want its value to be shown alongside the previously checked values. Right now, my code only displays one value at a time. Any suggestions on how to achie ...

Can you help me understand the process of assigning HTML form values to SESSION variables?

My current project involves an HTML form with 16 fields that can be viewed here: . I am seeking advice on the most efficient method to capture all field values and store them as SESSION variables. Would utilizing an array for this task be optimal, or is i ...

Unable to eliminate top padding without using universal selector

Trying to remove the top padding on a webpage, but encountering some difficulty. Here's the HTML code: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <link rel="stylesheet" href="style.css"> <title&g ...

How to automatically open JQuery Accordion panels when the page loads

My Accordion loads with the 1st panel open upon page load, but I am looking for a way to have the entire Accordion closed by default. Any help or suggestions on how to achieve this would be highly appreciated. Thank you for your assistance. FIDDLE http:// ...

Troubleshooting problems with the masonry layout in HTML (asp.net)

I'm working on my website and trying to implement masonry to achieve a nice layout for my content. However, I've been encountering some strange results so far. Below is the code I'm using: <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 ...

Why does Laravel DatePicker consistently default to showing the previous month instead of the selected month?

I've hit a roadblock trying to pinpoint the source of this error in the Tailwind UI Datepicker. Whenever I choose 09-08-2021 on the visual Datepicker, the value ends up saving as 09-07-2021. I've researched similar cases where the month value re ...