Adjusting the background color of the custom input range thumb when the input is disabled

I've customized the input thumb on my range slider, and I'm looking to change its color when it's disabled.

I attempted adding a class to the thumb like this:

input[type=range]::-webkit-slider-thumb.disabled

and also tried adding the disabled directive:

input[type=range]::-webkit-slider-thumb:disabled

but neither of these solutions are working.

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  border: 2px solid #ffffff;
  height: 22px;
  width: 22px;
  border-radius: 50%;
  background: linear-gradient(#FF6C2C,#FF2626);
  margin-top: -9px;
  z-index: 4;
}

I want it to look something like this:

input[type=range]::-webkit-slider-thumb:disabled {
  background: #CCCCCC;
}

Is there another way to achieve this? I'm unable to use jQuery for this task.

Answer №1

Forget about it, I have discovered the solution! It should be written as follows:

input[type=range].disabled::-webkit-slider-thumb{
  background: #CCCCCC;
}

The "disabled" class needs to come after input[type=range] for it to function correctly.

Answer №2

Once I started writing like this, magic began:

input[type="range"]:disabled::-webkit-slider-thumb {
  opacity: 0.6 !important;
  cursor: context-menu !important;
}

input[type="range"]:disabled::-moz-range-thumb {
  opacity: 0.6 !important;
  cursor: context-menu !important;
}

input[type="range"]:disabled::-ms-thumb {
  opacity: 0.6 !important;
  cursor: context-menu !important;
}
<input type="range" disabled />

Answer №3

#customslider{
  -webkit-appearance: none;
  outline:none;
  border: 2px solid #ffffff;
  border-radius: 20px;
  box-shadow: inset 0 0 5px rgba(0,0,0,1);
 overflow:hidden;
}

#customslider::-webkit-slider-thumb{
    -webkit-appearance: none;
    height: 15px;
      width: 15px;
      border-radius:50%; 
      background:#000000;
      box-shadow: -410px 0 0 400px #007bff;
      cursor:pointer;
}
 <input style="" type= "range" id="customslider" name="point_count" min= "0"   max = "100" value= "10" disabled >

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

Troubleshooting: Difficulty with jQuery's resize event handler not functioning properly with

I'm currently facing an issue where I want a divider to adjust its size when another divider changes size due to new content being loaded into it. However, even after binding the resize event handler to the divider that loads the content, the event do ...

Collaborate on sharing CSS and TypeScript code between multiple projects to

I am looking for a solution to efficiently share CSS and TS code across multiple Angular projects. Simply copy-pasting the code is not an ideal option. Is there a better way to achieve this? ...

Using a decorator with an abstract method

Discussing a specific class: export abstract class CanDeactivateComponent { abstract canLeavePage(): boolean; abstract onPageLeave(): void; @someDecorator abstract canDeactivateBeforeUnload(): boolean; } An error occurred stating that A decorat ...

Updating the appearance of a non-declared HTML child component on-the-fly using Angular

Trying to dynamically adjust the style of an unspecified div is causing some trouble. Using Angular and PrimeNG, invisible divs are being generated that I cannot access through inline styles. The objective is to allow a user to input a width as a string (5 ...

Guide on how to conditionally display a button or link in a Next.js Component using TypeScript

Encountering a frustrating issue with multiple typescript errors while attempting to conditionally render the Next.js Link component or a button element. If the href prop is passed, the intention is to render the Next.js built-in Link component; otherwise, ...

Achieve a sleek, modern look by using CSS to add a border with crisp square

Hello everyone, I'm currently attempting to add a border to only one side of an a element. However, when I add the border to just one side, it creates a sharp diagonal edge: https://i.stack.imgur.com/pAqMM.png My goal is to eliminate the sharp edge ...

The 'id' property is not found within the 'Order[]' type

Encountering a perplexing issue in my HTML where it keeps showing an error claiming that the 'id' property does not exist on type Order[] despite its clear existence The error message displayed: Property 'id' does not exist on type &ap ...

Expanding the rowspan within a table column has the effect of reducing its overall width

I have created a table with two rows, where the first row has three columns and the second row has two columns. The middle column in the first row has been set to rowspan="2". However, the issue is that it appears smaller than its intended width. .kolon ...

Troubleshooting: ngAnimate max-height failing to apply to specific element

Having integrated ngAnimate into a project to enhance animations, I've encountered some unusual behavior with a specific element. Let me provide some context: our website features a shop with categories and products within those categories. I am usin ...

Implement a CSS style for all upcoming elements

I'm currently developing a Chrome extension tailored for my personal needs. I am looking to implement a CSS rule that will be applied to all elements within a certain class, even if they are dynamically generated after the execution of my extension&ap ...

Steps for Adding a JSON Array into an Object in Angular

Here is a JSON Array that I have: 0: {name: "Jan", value: 12} 1: {name: "Mar", value: 14} 2: {name: "Feb", value: 11} 3: {name: "Apr", value: 10} 4: {name: "May", value: 14} 5: {name: "Jun", value ...

Troubleshooting issues with @HostListener in Angular2 RC1

Created a custom attribute directive called myOptional specifically for use with form inputs, to indicate that certain fields are optional. This is achieved by adding a class to the input and then displaying the optional text through css pseudo element ::a ...

Encountering issues with dependencies while updating React results in deployment failure for the React app

Ever since upgrading React to version 18, I've been encountering deployment issues. Despite following the documentation and scouring forums for solutions, I keep running into roadblocks with no success. The errors displayed are as follows: $ npm i np ...

Adjusting the image placement within a modal window (using bootstrap 3)

Behold, an example modal: <!-- Large Modal --> <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"> <div class="modal-dialog modal-lg"> <div class="modal-content"> ...

What is the best way to place a transparent navbar on top of a hero image while also adding a functional button to the hero image?

My navigation bar is set to be transparent on top of my hero image, but the buttons on the hero image are not clickable. The nav-bar has a z-index of 1, while my hero image, text, and button have a z-index of -1. This setup causes the button to be unclick ...

Type definition for Vuex store functionality

Working on creating a versatile type to provide typing hints for mutations in Vuex. After reading an inspiring article on Vuex + TypeScript, I decided to develop something more generic. Here is what I came up with: export type MutationType<S, P, K exten ...

Extracting Menu Information from Weedmaps

I've been attempting to extract menu data from dispensaries listed on weedmaps.com, but I'm struggling to understand how the website is structured and where the relevant information is located for scraping. My goal is simple: I want to retrieve ...

What is the best way to export Class methods as independent functions in TypeScript that can be dynamically assigned?

As I work on rewriting an old NPM module into TypeScript, I encountered an intriguing challenge. The existing module is structured like this - 1.1 my-module.js export function init(options) { //initialize module } export function doStuff(params) { ...

Angular2 API call error: The function .map defaultOptions.merge is not recognized

When attempting to call the API using the post method, I encountered the following error message: this._defaultOptions.merge is not a function ... I looked into some solutions and tried importing the following without success: import 'rxjs/add/ope ...

Guide on incorporating the font-awesome library in your project

Forgive me if this sounds like a silly question, but I am completely new to javascript and its libraries. I stumbled upon a similar issue as described in this thread, where the accepted solution included the following line: <link rel="stylesheet" href ...