CSS3 Transitioning Transforms in Mobile WebKit - css
I have a transition transform on an element in CSS3, but whenever I run the animation, it seems that one of the elements involved in the animation is always hidden for the duration of the animation.
Here is the CSS, HTML and JavaScript code:
CSS
div.toggle {
font-family: Arial, Helvetica, sans-serif;
width: 92px;
overflow: hidden;
cursor: default;
border-radius: 3px;
border: 1px solid #919191;
float: right;
position: relative;
height: 26px
}
div.toggle div.control-cont {
display: -webkit-box;
position: absolute;
-webkit-transition:all 0.2s ease-in-out;
width: 155px;
}
div.toggle span {
display: inline-block;
float: left;
text-transform: uppercase;
position: relative;
float: left;
}
div.toggle span.on {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(41,90,178,1)), color-stop(50%,rgba(64,133,236,1)), color-stop(51%,rgba(77,143,239,1)), color-stop(100%,rgba(118,173,252,1)));
background: -webkit-linear-gradient(top, rgba(41,90,178,1) 0%,rgba(64,133,236,1) 50%,rgba(77,143,239,1) 51%,rgba(118,173,252,1) 100%);
font-weight: bold;
color: #fff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5);
font-size: 16px;
width: 57px;
text-align: center;
padding-top: 4px;
}
div.toggle.important span.on {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(210,102,8,1)), color-stop(2%,rgba(234,115,10,1)), color-stop(4%,rgba(248,123,12,1)), color-stop(50%,rgba(255,140,14,1)), color-stop(51%,rgba(255,153,33,1)), color-stop(100%,rgba(254,188,86,1)));
background: -webkit-linear-gradient(top, rgba(210,102,8,1) 0%,rgba(234,115,10,1) 2%,rgba(248,123,12,1) 4%,rgba(255,140,14,1) 50%,rgba(255,153,33,1) 51%,rgba(254,188,86,1) 100%);
}
div.toggle span.handle {
border-radius: 3px;
height: 26px;
border-left: 1px solid #9f9f9f;
border-right: 1px solid #9f9f9f;
width: 39px;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(239,239,239,1)), color-stop(3%,rgba(206,206,206,1)), color-stop(100%,rgba(251,251,251,1)));
background: -webkit-linear-gradient(top, rgba(239,239,239,1) 0%,rgba(206,206,206,1) 3%,rgba(251,251,251,1) 100%);
z-index: 10;
left: -5px
}
div.toggle span.off {
font-size: 16px;
font-weight: bold;
color: #7e7e7e;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(181,181,181,1)), color-stop(2%,rgba(207,207,207,1)), color-stop(4%,rgba(223,223,223,1)), color-stop(6%,rgba(231,231,231,1)), color-stop(50%,rgba(239,239,239,1)), color-stop(51%,rgba(249,249,249,1)), color-stop(100%,rgba(254,254,254,1)), color-stop(100%,rgba(251,251,251,1)));
background: -webkit-linear-gradient(top, rgba(181,181,181,1) 0%,rgba(207,207,207,1) 2%,rgba(223,223,223,1) 4%,rgba(231,231,231,1) 6%,rgba(239,239,239,1) 50%,rgba(249,249,249,1) 51%,rgba(254,254,254,1) 100%,rgba(251,251,251,1) 100%);
left: -10px;
text-align: center;
padding-top: 4px;
width: 57px;
}
div.toggle input {
display: none;
}
JavaScript:
(function($) {
$.fn.toggle = function()
{
this.each(function() {
var toggle_class = ($(this).attr('checked')) ? 'checked' : '';
var important_class = ($(this).hasClass('important')) ? 'important' : '';
var this_transformed = false;
var this_toggle = $('<div class="toggle">\
<div class="control-cont">\
<span class="on">on</span>\
<span class="handle"></span>\
<span class="off">off</span>\
</div>\
</div>');
this_toggle.addClass(toggle_class);
this_toggle.addClass(important_class);
var thecheckbox = this;
$(this).replaceWith(this_toggle);
this_toggle.append(thecheckbox);
if(toggle_class != 'checked')
{
this_toggle.find('.control-cont').css({ left: '-53px' });
}
this_toggle.click(toggle_switch);
$(thecheckbox).change(toggle_switch);
function toggle_switch() {
var self = $(this);
var this_off = $(this).find('.off');
var this_on = $(this).find('.on');
var this_container = $(this).find('.control-cont');
var the_checkbox = $(this).find('input[type="checkbox"]');
if($(this).hasClass('checked'))
{
if(!this_transformed)
{
this_container.css("-webkit-transform", "translate(-53px, 0px)");
this_transformed = true;
}
else
{
this_container.css("-webkit-transform", "translate(53px, 0px)");
}
self.removeClass('checked');
the_checkbox.attr('checked', false);
}
else
{
if(!this_transformed)
{
this_container.css("-webkit-transform", "translate(53px, 0px)");
this_transformed = true;
}
else
{
this_container.css("-webkit-transform", "translate(0px, 0px)");
}
self.addClass('checked');
the_checkbox.attr('checked', true);
}
};
});
};
}) ( jQuery );
Essentially, the animation moves the entire div.control-con along or backwards, depending on the checkbox's status. Everything works fine in Chrome and Safari, but when running in Mobile Safari, for some reason the span.off and span.on elements are not displayed when the animation is run.
Which span element is hidden depends on the direction of the animation. Here's a screenshot of the problem, you'll notice that the span.off isn't displayed until the animation is complete:
I've also put this into a jsFiddle for reference: http://jsfiddle.net/kShEQ/
Mobile Safari is not an exact clone of normal safari and the webkit engine. It's a myth that there's a single webkit engine haha. Mobile Safari renders transitions differently. From what I've seen, the syntax in which you enter the transition values differs slightly. Check out this semi-similar stackoverflow question:
Scaling problem with -webkit-transform with mobile safari on iPad
Related
Autofill with LinkedIn form
I have applied the Linked Autofill function but I have 2 questions about it: Here is the page link : The page is hosted on HubSpot CMS - https://inboundmarketing.inboundmantra.com/inbound-marketing-company-contact-inbound-mantra Here is code of the linkedIn autofill button for the above page: <button id="autofill-button"> <span class="logo">IN</span> <div class="button-text-container"> <span class="button-text"> AutoFill with <strong>LinkedIn</strong> </span> </div> </button> <style> #autofill-button { height: 33px; width: 174px; cursor: pointer; color: #FFF; padding: 0; border: 1px #2D6FA8 solid; border-radius: 3px; font-size: 12px; position: relative; overflow: hidden; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; background: #79adcb; background: -webkit-linear-gradient(top, #79adcb 15%, #2373ac 100%); background: linear-gradient(to bottom, #79adcb 15%, #2373ac 100%); -ms-user-select: none; -moz-user-select: none; -webkit-user-select: none; user-select: none; font-family: Arial; font-size: 12px; display: inline-block; } #autofill-button:hover { background: #5a8193; background: -webkit-linear-gradient(top, #5a8193 15%, #1e4d72 100%); background: linear-gradient(to bottom, #5a8193 15%, #1e4d72 100%); } #autofill-button:active { background: #1e4d72; background: -webkit-linear-gradient(top, #1e4d72 15%, #5a8193 100%); background: linear-gradient(to bottom, #1e4d72 15%, #5a8193 100%); } #autofill-button .logo { position: absolute; top: 0; bottom: 0; right: 0; width: 34px; color: transparent; background: url(https://www.linkedin.com/scds/common/u/img/sprite/sprite_connect_v13.png) no-repeat scroll 0 -347px transparent; } #autofill-button .button-text-container { position: absolute; top: 0; bottom: 0; left: 0; right: 0; display: table; width: 171px; height: 33px; } #autofill-button .button-text { display: table-cell; vertical-align: middle; } span.IN-widget { height: 0 !important; visibility: hidden; opacity: 0; } </style> <script> $('#autofill-button').click(function(){ $('span.IN-widget *').click(); }); </script> <script type="in/Login"></script> <script type="text/javascript" src="//platform.linkedin.com/in.js">// <![CDATA[ api_key: 81ndwffuhqmres authorize: false lang: en_US </script> <script> setTimeout(function(){ var callbackScope, extraData; function callback(args) { var fields = ['first-name', 'last-name', 'email-address', 'id', 'headline', 'pictureUrl', 'positions', 'num-connections']; IN.API.Profile("me").fields(fields).result(function(profiles) { member = profiles.values[0]; console.log(member); $('[id*="firstname"]').val(member.firstName); $('[id*="lastname"]').val(member.lastName); $('[id*="email"]').val(member.emailAddress); $('#headline').val(member.headline); $('#picture').attr("src", member.pictureUrl); var i = 0; for (position of member.positions.values) { $('#position' + (i++)).val(position.company.name + " - " + position.title); } }).error(function(data) { console.log(data); }); } IN.Event.on(IN, 'auth', callback, callbackScope, extraData); },500); </script> There are entire fields autofilled but the phone number field is not working. This code is not working when I'm running this code in WordPress. Here is the page link : https://www.inboundmantra.com/predictive-lead-scoring Please let me know how to fix it. Thanks in advance...
have you whitelisted your domain? you need to contact a linkedin representative to whitelist your domain in order to use this feature.
CSS - Custom cursor that changes depending on hovered element flickers when moving left to right but not right to left
I am trying to create a custom cursor that changes when hovering over a <div>, but there is a flicker when moving left to right across it, but not when moving right to left. Why this is happening and what I can do to fix it? document.addEventListener('mousemove', (ev) => cursorMove(ev)); function cursorMove(ev) { let circle = document.getElementById('circle'); let posY = ev.clientY; let posX = ev.clientX; circle.style.top = posY + 'px'; circle.style.left = posX + 'px'; } body { margin: 0; height: 100vh; background-color: #acd1d2; position: relative; display: flex; justify-content: center; align-items: center; font-family: monospace; } #wrapper { position: relative; width: 70%; height: 80%; } .box { height: 25%; margin: 0; display: flex; justify-content: center; align-items: center; } #box-1 { background-color: #e8edf3; } #box-1:hover ~ #circle { background-color: #e6cf8b; box-shadow:inset 0em -0.3em 0.4em 0.2em #ca9e03a6; } #box-2 { background-color: #e6cf8b; } #box-2:hover ~ #circle { background-color: transparent; border: 3px solid #E91E63; } #box-3 { background-color: #b56969; } #box-3:hover ~ #circle { height: 1em; width: 1em; background-color: #e6cf8b; } #box-4 { background-color: #22264b; color: white; } #box-4:hover ~ #circle { background-image: linear-gradient(to top, #fbc2eb 0%, #a6c1ee 100%); } #circle { position: fixed; border-radius: 50%; z-index: 5; height: 32px; width: 32px; background-color: white; } <div id="wrapper"> <div id="box-1" class="box">Sphere</div> <div id="box-2" class="box">Circle outline</div> <div id="box-3" class="box">Circle pin</div> <div id="box-4" class="box">Circle color gradient</div> <div id="circle"></div> </div>
That's because your mouse moves faster than the circle and you hover over it, so the styles that apply to it are the same ones than when the cursor is on the background green/blue-ish area of the page. You can fix that by adding pointer-events: none to the circle so that it feels a bit like this: Ok, where were we? Oh yes... So you should use position: fixed instead of absolute (as you really want your cursor to be positioned relative to the top-left corner of the viewport) and probably window.requestAnimationFrame to get a smoother animation and translate3d(0, 0, 0) to promote the element to its own layer and enable hardware-accelerated rendering, which will also contribute to make it feel smoother. You could also hide the default cursor with cursor: none and center the circle where the arrowhead of the cursor is to make it feel just like a real cursor. const circle = document.getElementById('circle'); const circleStyle = circle.style; document.addEventListener('mousemove', e => { window.requestAnimationFrame(() => { circleStyle.top = `${ e.clientY - circle.offsetHeight/2 }px`; circleStyle.left = `${ e.clientX - circle.offsetWidth/2 }px`; }); }); body { margin: 0; height: 100vh; background-color: #acd1d2; position: relative; display: flex; justify-content: center; align-items: center; font-family: monospace; cursor: none; } #wrapper { position: relative; width: 70%; height: 80%; } #circle { position: fixed; border-radius: 50%; z-index: 5; height: 32px; width: 32px; background-color: white; pointer-events: none; transition: background ease-in 10ms, box-shadow ease-in 150ms, transform ease-in 150ms; /* Promote it to its own layer to enable hardware accelerated rendering: */ transform: translate3d(0, 0, 0); } .box { height: 25%; margin: 0; display: flex; justify-content: center; align-items: center; } #box-1 { background-color: #e8edf3; } #box-1:hover ~ #circle { background-color: #e6cf8b; box-shadow: 0 0 0 0 transparent, inset 0em -0.3em 0.4em 0.2em #ca9e03a6; } #box-2 { background-color: #e6cf8b; } #box-2:hover ~ #circle { background-color: transparent; /* Use box-shadow instead of border to avoid changing the dimensions of the cursor, which will make it be off-center until the mouse moves again: */ aborder: 3px solid #E91E63; box-shadow: 0 0 0 3px #E91E63; } #box-3 { background-color: #b56969; } #box-3:hover ~ #circle { background-color: #e6cf8b; /* Change its size with scale() instead of width and height for better performance performance: */ transform: scale(0.5) translate3d(0, 0, 0); } #box-4 { background-color: #22264b; color: white; } #box-4:hover ~ #circle { background-image: linear-gradient(to top, #fbc2eb 0%, #a6c1ee 100%); } <div id="wrapper"> <div id="box-1" class="box">Sphere</div> <div id="box-2" class="box">Circle outline</div> <div id="box-3" class="box">Circle pin</div> <div id="box-4" class="box">Circle color gradient</div> <div id="circle"></div> </div> Here you can see another cool example I made of a custom cursor using CSS that resembles a torch: How to darken a CSS background image but keep area around cursor brighter. Also, you can check out the cursor on my website, which is quite similar to what you have done as it has animations/transitions between its different shapes or states. 🚀 Check it out here: https://gmzcodes.com/. 👨💻 Check the code here: https://github.com/Danziger/gmzcodes
How to change -webkit-scrollbar width when hover on it
I want to change the scrollbar width wider, so it looks clear when user hover on it. So I wrote: ::-webkit-scrollbar { width: 7px; height: 7px; background-color: #ddd; } ::-webkit-scrollbar:hover { width: 10px; height: 10px; background-color: red; } The background color changed to red, but not the width, Is there anyway to solve this? Here is plnkr
*:hover::-webkit-scrollbar { width: 10px; height: 10px; } This will change the width and height of any element's scrollbar. If you want to be more specific, just exchange the '*' to a selector of your choice. For instance, to apply it to scrollbars of elements with the class of 'my-custom-scrollbar': .my-custom-scrollbar:hover::-webkit-scrollbar { width: 10px; height: 10px; }
You can achieve that by using border instead of width: ::-webkit-scrollbar { width: 7px; height: 7px; } ::-webkit-scrollbar-thumb { background: #ababab; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; // <== make the border work } ::-webkit-scrollbar-thumb:hover{ border: 0; } ::-webkit-scrollbar-track { background: transparent; }
this is a workaround I used using mousemove event: document.addEventListener("mousemove", function(e){ let ele = document.getElementById('element'); let distance = ele.offsetLeft + ele.offsetWidth - e.pageX; distance < 15 && distance > -15 ? ele.classList.add('more-width') : ele.classList.remove('more-width'); }); and styling would be #element::-webkit-scrollbar-thumb { background: #888; } #element::-webkit-scrollbar { width: 5px; } #element.more-width::-webkit-scrollbar { width: 10px; } codepen sample: https://codepen.io/KhaleD_D/pen/OJpgJKM
This solution uses scrollbar which is natively 16px large, but we show only 6px to make it thinner (and leave more space for content). But the trick is overflow: overlay which allows content to be displayed even over scrollbar area. Using this approach you have thin scrollbar which enlarges on hover (and the hover are is a bit wider). I got inspired by Khaled's solution, but I used CSS only approach: .custom-scrollbar { scrollbar-color: var(--gray) var(--secondary); scrollbar-width: thin; overflow: overlay !important; } .custom-scrollbar::-webkit-scrollbar { width: 16px; height: 16px; background: transparent; } .custom-scrollbar::-webkit-scrollbar-track-piece { background: transparent; } .custom-scrollbar::-webkit-scrollbar-thumb:vertical { background: linear-gradient(to left, var(--gray) 6px, transparent 0%); } .custom-scrollbar::-webkit-scrollbar-thumb:horizontal { background: linear-gradient(to bottom, var(--gray) 6px, transparent 0%); } .custom-scrollbar::-webkit-scrollbar-thumb:hover { background: var(--gray); }
I use following code to achieve increase width on hover effect. Sadly, its working on Chrome and Edge only. My apologies for incorrect formatting. * { &::-webkit-scrollbar-thumb { border: 5px solid transparent; border-radius: 10px; background-color: grey; background-clip: content-box; -webkit-background-clip: content-box; } &::-webkit-scrollbar-thumb:hover { background-color: black; background-clip: border-box; -webkit-background-clip: border-box; } &::-webkit-scrollbar { width: 16px; height: 16px; background-color: transparent; } }
Opacity on body not affecting background color on body
I am trying to set an opacity on the body. However, I have run into an issue. When setting the opacity on the body, only its content will be affected. The background is not affected by the opacity. $("button").click(function() { $("body").toggleClass("opacity"); }); * { box-sizing: border-box; } body { background: linear-gradient(to right, #1BBCB1, #37B9E9); font-family: 'Arial'; margin: 0; text-align: center; opacity: 1; } body.opacity { opacity: .3; } button { background-color: transparent; border: 2px solid #000; border-radius: 3px; margin-top: 15px; padding: 10px; cursor: pointer; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <p>The background gradient disapears when I set the opacity smaller then 1</p> <button>Toggle opacity</button> When doing the same on a div it works fine. $("button").click(function() { $("div").toggleClass("opacity"); }); * { box-sizing: border-box; } body { font-family: 'Arial'; margin: 0; text-align: center; } div { background: linear-gradient(to right, #1BBCB1, #37B9E9); opacity: 1; } div.opacity { opacity: .3; } button { background-color: transparent; border: 2px solid #000; border-radius: 3px; margin-top: 15px; padding: 10px; cursor: pointer; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div> <p>The background gradient disapears when I set the opacity smaller than 1</p> <button>Toggle opacity</button> </div> But I can't do this with a div. I have to set it on the body. How can I make the opacity affect the body's background? P.S. Happy new year!
This is because the background of body is propagated to the html element (since this one doesn't have a background set) thus the html is also having the same background of the body. In your case, the opacity works fine with background also but you simply see the one of the html element. Add a background to html to see the difference: $("button").click(function() { $("body").toggleClass("opacity"); }); * { box-sizing: border-box; } html { background:red; } body { background: linear-gradient(to right, #1BBCB1, #37B9E9); font-family: 'Arial'; margin: 0; text-align: center; opacity: 1; } body.opacity { opacity: .3; } button { background-color: transparent; border: 2px solid #000; border-radius: 3px; margin-top: 15px; padding: 10px; cursor: pointer; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <p>The background gradient disapears when I set the opacity smaller then 1</p> <button>Toggle opacity</button> Some usefull links to understand this behavior: https://www.w3.org/TR/css-backgrounds-3/#special-backgrounds https://css-tricks.com/just-one-of-those-weird-things-about-css-background-on-body/ https://stackoverflow.com/a/47998865/8620333 What's the meaning of "propagated to the viewport" in the CSS spec?
Use rgba() for your linear gradient colors. That way you can set the transparency of the colors. By default have the alpha transparency value set to 1 (a.k.a. 100% opacity = no transparency). Then change the value to something less than 1 so the background becomes semi-transparent. Note: This solution will only affect the background and not child elements. Of which, may or may not be the intended result. $("button").click(function() { $("body").toggleClass("opacity"); }); * { box-sizing: border-box; } body { background: linear-gradient(to right, rgba(27, 188, 177, 1), rgba(55, 185, 233, 1)); font-family: 'Arial'; margin: 0; text-align: center; opacity: 1; } body.opacity { background: linear-gradient(to right, rgba(27, 188, 177, 0.3), rgba(55, 185, 233, 0.3)); } button { background-color: transparent; border: 2px solid #000; border-radius: 3px; margin-top: 15px; padding: 10px; cursor: pointer; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <p>The background gradient disapears when I set the opacity smaller than 1</p> <button>Toggle opacity</button>
As far as I know, the opacity property of the body does not exist. So you can obtain the desired effect with something like this: https://codepen.io/calexandru/pen/YYQLmW $( function () { $("#target").on("click", function() { $('body').addClass('opacity-container'); }); } ); .opacity-container::after { /*CSS*/ content: ""; background: url(https://firebasestorage.googleapis.com/v0/b/betaproject-8a669.appspot.com/o/Quote-Generator%2F1.jpg?alt=media&token=4de18117-665f-4166-9111-4401af0cd555); opacity: 0.5; top: 0; left: 0; bottom: 0; right: 0; position: absolute; z-index: -1; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <p>Click the button for background with opacity</p> <button id="target">Click me</button>
How to fill HTML5 input[type=range] on the left side of the thumb with CSS only?
Is there a possibility to get the same effect as ::-ms-fill-lower on Firefox? Without using JS? I've already found a workaround in order to achieve that effect on webkit based browsers (e.g. Google Chrome) which uses the pseudo elements :before and :after. But it won't work on the Firefox elements. It seems like ::-moz-range-thumb::before and ::-moz-range-thumb::after aren't legal operations on Firefox, while Google Chrome supports ::-webkit-slider-thumb::before and ::-webkit-slider-thumb::after Here's a fiddle of the basic outline for the Firefox version: input[type="range"].slider-track { border: none; margin: 10px 0; width: 100%; height: 30px; padding: 0; overflow-x: hidden; overflow-y: visible; background: transparent; } input[type="range"].slider-track::-moz-range-thumb { box-shadow: none; border: 2px solid grey; height: 16px; width: 16px; border-radius: 16px; background: white; } input[type="range"].slider-track::-moz-range-track { width: 100%; height: 2px; box-shadow: none; background: blue; border-radius: 0px; border: 0px; } <div style="max-width: 380px;"> <input type="range" class="slider-track" id="mySlider1"></input> </div>
Sorry! I've found the answer 20 minutes after posting this... I was searching for that all day long... Here's the answer: Use the ::-moz-range-progress element! Example (works for the snippet) input[type="range"].slider-track::-moz-range-progress { background: red; }
Here you are in Vanilla JS - using gradients for Chrome range input: <div class="chrome"> <input id="myinput" type="range" value="50" /> </div> #myinput {background: linear-gradient(to right, #82CFD0 0%, #82CFD0 50%, #fff 50%, #fff 100%); border: solid 1px #82CFD0; border-radius: 8px; height: 7px; width: 356px; outline: none; transition: background 450ms ease-in; -webkit-appearance: none; } document.getElementById("myinput").oninput = function() { this.style.background = 'linear-gradient(to right, #82CFD0 0%, #82CFD0 '+this.value +'%, #fff ' + this.value + '%, white 100%)' }; https://codepen.io/saintwycliffe/pen/VBGYXN
You can try this : $('input[type="range"]').change(function () { var val = $(this).val()/100; $(this).css('background-image', '-webkit-gradient(linear, left top, right top, ' + 'color-stop(' + val + ', #94A14E), ' + 'color-stop(' + val + ', #C5C5C5)' + ')' ); }); input[type="range"]{ -webkit-appearance: none; -moz-apperance: none; border-radius: 6px; height: 6px; background-image: -webkit-gradient( linear, left top, right top, color-stop(0.15, #94A14E), color-stop(0.15, #C5C5C5) ); } input[type='range']::-webkit-slider-thumb { -webkit-appearance: none !important; background-color: #E9E9E9; border: 1px solid #CECECE; height: 15px; width: 15px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="range" min="0" max="100" step="1" value="15">
use input change instead of change, so in all browsers the color should fill up while the user is dragging, and not when the user stops dragging $(document).on('input change', '#slider', function() { // codes });