Using Bootstrap to style the <option> element with RGBA colors

Struggling to figure this out and seeking assistance. I have a form using bootstrap where I can apply rgba color for my select tag but not for the options.

Select CSS:

select {
    background-color: rgba(0,0,0,0.25) !important;
    border: 1px solid rgba(255,255,255,0.25) !important;
    color: #fff !important;
    min-height: 30px !important;
    padding-right: 6px !important;
    transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s !important;

}

Options CSS:

select option {
    width: 100%;
    background-color: rgba(0,0,0,0.35) !important;
    
    -webkit-appearance: none; 
    -moz-appearance: none;
}

Recreated with ul and li:

ul.dropdown{ 
    display: block;
    position: relative;
    width: 100%;
    height: 34px;
    font-size: 14px;
    line-height: 1.42857143;
    background-color: rgba(0,0,0,0.25) !important;
    border: 1px solid rgba(255,255,255,0.25) !important;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
    -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
    -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
    transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
ul.dropdown ul {
    width: 100%;
    background-color: rgba(0,0,0,0.35) !important;
    visibility: hidden; 
    position: absolute;
    list-style-type: none;
    top: 100%;
    left: 0; 
    padding: 0px;
}

Desired look for select/option:

Questions:

1) Is there a default background setting in Bootstrap or Chrome that affects RGBA styling, and how do I override it to match the ul/li design?

2) Are there any jquery plugins to mimic the select/option functionality on ul/li while avoiding interference from Bootstrap's styles?

Most solutions I've found use select/option with limited styling, and I'm concerned about Bootstrap's impact.

Thank you for your assistance.

Answer №1

When using Bootstrap, the .dropdown-menu class is applied to the select element that has been converted to a ul. To customize the styling of this dropdown menu, you can simply override this class.

ul.dropdown-menu
{
  background-color: brown;
}

ul.dropdown-menu li a:hover
{
 background-color: orange; 
}

For an example, refer to this JSFiddle link.

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

Transform inline styles in React to CSS declarations

Is there a tool available that can convert React inline style descriptions into CSS rules? For example: { minHeight: 200, position: 'relative', flexGrow: 1, flexShrink: 1, display: 'flex', flexDirection: ' ...

Having trouble retrieving text from an HTML form in Node.js using express, as the req.body object is coming up

Having trouble extracting text from an HTML form to build a basic text to speech functionality. Despite using an express server, the req.body is consistently empty when attempting to fetch the text. I've experimented with body-parser and adjusted the ...

Could the absence of a tree view in the div be due to an error in the positioning of the DOM

I'm currently working on displaying a tree structure with specific child elements inside a div using JavaScript and HTML. Despite creating all the necessary objects and ensuring that the data is correctly read from the JSON file (refer to the "data" i ...

Round progress indicator with directional pointer

I've been working on creating a round progress bar that features an arrow at the front. This is my current progress: HTML Code: <!-- Container --> <ul class="progress"> <!-- Item --> <li data-name="Item 1& ...

Filtering images by their class using a drop-down menu allows for easier organization and sorting based

While browsing around, I came across another inquiry regarding filtering images by category using input form and jQuery. It was similar to what I am trying to achieve. I experimented with some JSFiddles but unfortunately had no luck. If you're curiou ...

Creating a customized design for a q-popup-edit

As I navigate through using Quasar in Vue, I stumbled upon a q-popup-edit that allows me to gather input from the user. Despite my attempts at researching via Google and reading documentation, I have hit a roadblock when it comes to customizing the style o ...

Pause the ajax response using jQuery

I encountered a simple issue that is causing me trouble. It seems that when I send an ajax request, there isn't enough time to assign the value to the combonews variable: jQuery.ajax({ type: "POST", url: "People.aspx/LoadCombo ...

Step-by-step guide on how to configure the URL path in an AJAX function call

How can I dynamically set the URL path in an AJAX function call when clicking on a page so that the page name is included in the URL? For example, if I click on a particular page (let's say the "ask" page on Stack Overflow), the URL should look like: ...

Calculating the total amount by combining the quantity and price fields in

I currently have multiple tables generated dynamically using PHP <table class="table11"> <tbody> <tr> <td>Name</td> <td class="quantity">2</td> <td class="price">20</td> & ...

Forced Landscape Viewing on Mobile Site with No Auto-Rotation

My website is equipped with a mobile stylesheet: <link rel="stylesheet" href="css/mobile.css" media="handheld"> In addition to that, I am utilizing jQuery to customize functionality for mobile devices. I am wondering if there is a method to enforc ...

How can I achieve a floating effect for a div element that is contained within another element?

I have a container located within the body of my webpage. This container has margins on the left and right, as well as a specified width. Inside this container, there is a div element that extends beyond the boundaries of the container to cover the entire ...

The jQuery variable appears to be failing to update after the completion of an ajax request

Every time I click the load more button, it is supposed to display 10 new results. However, the offset value does not update and as a result, I keep seeing the same set of 10 results repeatedly. $("#loadmore_timeline").on("click",functi ...

Troubleshoot: Dropdown menu in Materialize not functioning (menu fails to drop down

I am currently incorporating Materialize to create a dropdown button in my navigation bar. However, I am facing an issue where nothing happens when the button is clicked. Here is a snippet of my code: <head> <meta charset="UTF-8"> <!-- ...

Django does not support CSS styling out of the box

My webpage is rendering HTML correctly, but the CSS styles are not being applied. I am currently in development mode and running the django dev runserver. STATICFILES_DIRS = ("C:/Users/user/site/sitemain/static",) STATIC_ROOT= '' STATIC_URL = ...

What advantages does including @charset "ISO-8859-15"; at the top of a CSS file provide?

Why would adding @charset "ISO-8859-15"; or @charset "utf-8"; at the beginning of a CSS file be advantageous? ...

Why are my images only 1 pixel tall in Internet Explorer 8?

<img src="blah.png" width="150" height="auto"> When viewed in Firefox, Chrome, or Safari, the image will appear as intended. However, Internet Explorer may cause the image to display at a height of only 1 pixel while maintaining the width of 150 pix ...

Elastic_Frame | "Error: Unable to process action as property 'toLowerCase' is not defined"

Attempting to create a personal and project portfolio using Vu Khanh Truong's "elastic_grid" jQuery plugin for the actual portfolio. You can access it here. However, encountering some issues on my page: 1) The header for the portfolio section disappe ...

Adjust the z-index of the dynamically generated image label to ensure that it is not obscured by the image

Currently, I am working on implementing drag and drop functionality where users can drag multiple images and drop them into a div. Once the user clicks on a button, a p tag is dynamically appended as a label to each image. My issue arises when two images ...

Troubleshooting: JavaScript code not functioning properly with variable input instead of fixed value

I have encountered an issue with a JS function that I'm using. The function is shown below: // A simple array where we keep track of things that are filed. filed = []; function fileIt(thing) { // Dynamically call the file method of whatever ' ...

Having trouble getting the .toggle() function with classList to work on one element, despite working fine on others

I've been struggling to apply a class to an HTML element when I click on another element of the page. Despite numerous attempts, it just doesn't seem to work for me. Let's take a look at my code: HTML Code: <div class="container&qu ...