html input range style using background-image - html

I ma trying to style input range and progress. The issue is they are not aligned on top of each other. I dont want to use margin-top on -webkit-slider-runnable-track because I found it doesnt work in some cases (depending on where parent element is positioned).
:root {
--value: 30%;
}
.seekbar-wrap{
background: #353b49;
}
.seekbar {
overflow: hidden;
height: 50px;
cursor: pointer;
flex: 1;
}
.seekbar-wrap {
position: relative;
margin: 0 10px;
height: 50px;
}
.load-level {
position: absolute;
top: 23px;
width: 100%;
-webkit-appearance: none;
appearance: none;
background: 0 0;
border: 0;
height: 5px;
left: 0;
padding: 0;
}
.load-level::-webkit-progress-bar{
background:none;
}
.load-level::-webkit-progress-value{
background-color:#b6bfc1;
}
.load-level::-moz-progress-bar{
background-color:#b6bfc1;
}
.input-progress {
position: absolute;
width: 100%;
left: 0;
top: 0;
height: 50px;
cursor: pointer;
-webkit-appearance: none;
appearance: none;
background: 0 0;
border: 0;
color: #62768f;
margin: 0;
min-width: 0;
padding: 0;
}
.input-progress::-webkit-slider-runnable-track {
background-image:linear-gradient(to right,currentColor var(--value,0),transparent var(--value,0));
border: 0;
height: 5px;
-webkit-user-select: none;
user-select: none;
}
.input-progress::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
border: 0;
width: 0;
height: 0;
}
.input-progress::-moz-range-track {
height: 5px;
border: 0;
background-image:linear-gradient(to right,currentColor var(--value,0),transparent var(--value,0));
}
.input-progress::-moz-range-progress {
}
.input-progress::-moz-range-thumb {
appearance: none;
background: #fff;
border: 0;
height: 0;
width: 0;
}
<div class="seekbar-wrap">
<progress class="load-level" min="0" max="100" role="progressbar" value="44.11733725" aria-hidden="true">% buffered</progress>
<input class="input-progress" type="range" min="0" max="100" step="0.01" autocomplete="off" role="slider" aria-label="Seek" aria-valuemin="0" aria-valuemax="235" aria-valuenow="17.052851513822205" value="0" aria-valuetext="00:01 of 00:20" style="user-select: none; touch-action: manipulation;">
</div>

I don't know if I fully understood what you mean, but maybe this CSS code could help:
:root {
--value: 30%;
}
.seekbar-wrap{
background: #353b49;
}
.seekbar {
overflow: hidden;
height: 50px;
cursor: pointer;
flex: 1;
}
.seekbar-wrap {
position: relative;
margin: 0 10px;
height: 50px;
display:flex;
}
.load-level {
/* position: absolute; */
top: 23px;
width: 100%;
-webkit-appearance: none;
appearance: none;
background: 0 0;
border: 0;
height: 5px;
left: 0;
padding: 0;
}
.load-level::-webkit-progress-bar{
background:none;
}
.load-level::-webkit-progress-value{
background-color:#b6bfc1;
}
.load-level::-moz-progress-bar{
background-color:#b6bfc1;
}
.input-progress {
position: absolute;
width: 100%;
left: 0;
top: 0;
cursor: pointer;
-webkit-appearance: none;
appearance: none;
background: 0 0;
border: 0;
color: #62768f;
margin: 0;
min-width: 0;
padding: 0;
}
.input-progress::-webkit-slider-runnable-track {
background-image:linear-gradient(to right,currentColor var(--value,0),transparent var(--value,0));
border: 0;
height: 5px;
-webkit-user-select: none;
user-select: none;
}
.input-progress::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
border: 0;
width: 0;
height: 0;
}
.input-progress::-moz-range-track {
height: 5px;
border: 0;
background-image:linear-gradient(to right,currentColor var(--value,0),transparent var(--value,0));
}
.input-progress::-moz-range-progress {
}
.input-progress::-moz-range-thumb {
appearance: none;
background: #fff;
border: 0;
height: 0;
width: 0;
}

Related

Styles apply improperly to an audio element when viewed on mobile

Here is how the player should look like, the text and the play icon invert colors beneath them, so they are still visible. This works on PC:
However, on mobile browser (Safari) text inversion works, but the play button stays white so it's not visible when the progress bar passes through it:
Here is CSS for my player:
*:focus {
outline: none;
}
#audioshadow {
position: fixed;
bottom: 0;
}
#audioshadow img {
max-height: 1000px;
padding-bottom: 80px;
width: 100%;
z-index: 0;
transition: 0.4s ease-in-out;
max-width: 600px;
display: none;
}
#audiodiv:hover ~ #audioshadow img {
display: initial;
}
#volume-slider-container {
z-index: 1;
}
/* COLOR OVERLAY */
#color-switch {
width: 100%;
max-width: 608px;
height: 100%;
max-height: 38px;
position: relative;
}
#color-switch img {
position: absolute;
object-fit: cover;
width: 100%;
height: 100%;
z-index: 99;
mix-blend-mode: lighten;
pointer-events: none;
}
/* BUTTONS */
button {
padding: 0;
margin-top: 4px;
border: 0;
cursor: pointer;
outline: none;
width: 25px;
height: 25px;
}
#play-icon {
position: absolute;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
width: 25px;
height: 25px;
transform: scale(1.2);
z-index: 1;
filter: invert(1);
mix-blend-mode: difference;
background: transparent;
}
path {
stroke: #fff;
fill: #fff;
mix-blend-mode: difference;
object-fit: cover;
}
button.navigation-button-info {
margin-top: 0;
}
button.navigation-button-nwsletter {
margin-top: 0;
}
#mute-icon {
float: left;
display: none;
width: 18px;
height: 18px;
margin-top: -1px;
background: transparent;
}
/* WRAPS */
#player {
--seek-before-width: 0%;
--volume-before-width: 100%;
--buffered-width: 0%;
max-height: 80px;
height: 100%;
max-width: 608px;
width: 100%;
z-index: 999;
user-select: none;
}
#audio-player-container {
position: relative;
max-width: 600px;
height: 32px;
border: 4px solid white;
z-index: 1;
/* background color */
background-color: #000;
}
#volume-slider-container {
position: absolute;
display: flex;
top: -30px;
max-width: 608px;
width: 100%;
height: 30px;
content-align: center;
justify-content: space-between;
align-items: center;
gap: 8px;
opacity: 0;
-webkit-transition: all 500ms ease-in-out;
-moz-transition: all 500ms ease-in-out;
-ms-transition: all 500ms ease-in-out;
-o-transition: all 500ms ease-in-out;
transition: all 500ms ease-in-out;
}
#player:hover #volume-slider-container {
opacity: 1;
}
#volume-slider {
opacity: 0;
position: relative;
z-index: 10;
transform: scaleY(5.5);
}
#volume-slider-squish {
position: relative;
}
#volume-slider-squish::after {
content: '';
position: absolute;
top: 0;
left: 0;
z-index: 0;
display: block;
width: var(--volume-before-width, 0);
height: 100%;
background-color: #fff;
}
#audio-player-container::before {
position: absolute;
content: '';
}
/* OUTPUTS + TEXT */
.time {
width: 32px;
text-align: center;
line-height: 32px;
color: #fff;
mix-blend-mode: difference;
font-weight: 700;
letter-spacing: -1px;
font-size: 14px;
font-family: 'Inter', sans-serif;
}
#duration {
position: absolute;
right: 10px;
z-index: 1;
}
#current-time {
position: absolute;
left: 10px;
z-index: 1;
}
output {
width: 18px;
height: 40px;
line-height: 40px;
text-align: center;
font-size: 12px;
float: left;
clear: left;
color: #fff;
float: left;
}
/* SLIDERS */
input[type="range"] {
position: relative;
-webkit-appearance: none;
width: 100%;
margin: 0;
padding: 0;
height: 32px;
float: left;
border-radius: 0;
z-index: 0;
cursor: default;
}
input[type="range"]::-webkit-slider-runnable-track {
width: 100%;
height: 32px;
cursor: default;
/* COLOR AFTER */
background-color: #000;
}
input[type="range"]::before {
position: absolute;
content: "";
left: 0;
width: var(--seek-before-width);
height: 32px;
/* COLOR BEFORE */
background-color: #fff;
cursor: default;
}
input[type="range"]::-webkit-slider-thumb {
opacity: 0;
cursor: default;
}
input[type="range"]:hover::-webkit-slider-thumb {
opacity: 0;
cursor: default;
}
input[type="range"]:active::-webkit-slider-thumb {
opacity: 0;
cursor: default;
}
input[type="range"]::-moz-range-track {
width: 100%;
height: 32px;
cursor: default;
background-color: black;
}
input[type="range"]::-moz-range-progress {
background-color: white;
height: 32px;
}
input[type="range"]::-moz-focus-outer {
border: 0;
cursor: default;
}
input[type="range"]::-moz-range-thumb {
opacity: 0;
cursor: default;
}
input[type="range"]:active::-moz-range-thumb {
opacity: 0;
cursor: default;
}
input[type="range"]::-ms-track {
width: 100%;
height: 32px;
cursor: default;
background: transparent;
}
input[type="range"]::-ms-fill-lower {
background-color: transparent;
cursor: default;
}
input[type="range"]::-ms-fill-upper {
background: transparent;
cursor: default;
}
input[type="range"]::-ms-thumb {
opacity: 0;
cursor: default;
}
input[type="range"]:active::-ms-thumb {
opacity: 0;
cursor: default;
}
#volume-slider {
float: left;
}
#volume-slider-squish {
width: 100%;
height: 4px;
float: left;
/* background-color: blue; */
background-color: rgba(0, 0, 0, 0.3);
}
#volume-slider::-webkit-slider-runnable-track {
background: rgba(0, 0, 0, 0.5);
float: left;
height: 4px;
}
#volume-slider::-moz-range-track {
background: rgba(0, 0, 0, 0.5);
float: left;
height: 4px;
}
#volume-slider::-ms-fill-upper {
background: rgba(0, 0, 0, 0.5);
float: left;
height: 4px;
}
#volume-slider::before {
width: var(--volume-before-width);
float: left;
height: 4px;
}
#volume-slider-squish>input[type="range"] {
height: 4px;
}
#volume-slider-squish>input[type="range"] {
height: 4px;
}
#volume-slider-squish>input[type="range"]::-webkit-slider-runnable-track {
height: 4px;
}
#volume-slider-squish>input[type="range"]::before {
height: 4px;
}
#volume-slider-squish>input[type="range"]::-webkit-slider-thumb {
height: 4px;
width: 4px;
background-color: #fff;
transform: scale(1);
opacity: 1;
}
#volume-slider-squish>input[type="range"]:hover::-webkit-slider-thumb {
height: 4px;
width: 4px;
transform: scale(1);
opacity: 1;
}
#volume-slider-squish>input[type="range"]:active::-webkit-slider-thumb {
height: 4px;
width: 4px;
transform: scale(1);
opacity: 1;
}
#volume-slider-squish>input[type="range"]::-moz-range-track {
height: 4px;
}
#volume-slider-squish>input[type="range"]::-moz-range-progress {
height: 4px;
}
#volume-slider-squish>input[type="range"]::-moz-focus-outer {
height: 4px;
}
#volume-slider-squish>input[type="range"]::-moz-range-thumb {
height: 4px;
}
#volume-slider-squish>input[type="range"]:active::-moz-range-thumb {
height: 4px;
}
#volume-slider-squish>input[type="range"]::-ms-track {
height: 4px;
}
#volume-slider-squish>input[type="range"]::-ms-fill-lower {
height: 4px;
}
#volume-slider-squish>input[type="range"]::-ms-fill-upper {
height: 4px;
}
#volume-slider-squish>input[type="range"]::-ms-thumb {
height: 4px;
}
#volume-slider-squish>input[type="range"]:active::-ms-thumb {
height: 4px;
}
And here is HTML for it:
<!-- PLAYER -->
<div id="player">
<!-- CHANGE PLAYER COLOR -->
<div id="color-switch"><img src="https://i.imgur.com/SYyiJUa.png">
<div id="volume-slider-container">
<output id="volume-output">100</output>
<div id="volume-slider-squish">
<input type="range" id="volume-slider" max="100" value="70">
</div>
<button id="mute-icon"></button>
</div>
<div id="audio-player-container">
<audio src="https://assets.codepen.io/4358584/Anitek_-_Komorebi.mp3" preload="metadata" loop></audio>
<button id="play-icon"></button>
<span id="current-time" class="time">0:00</span>
<input type="range" id="seek-slider" max="100" value="0">
<span id="duration" class="time">0:00</span>
</div>
</div>
</div>

Multi Range Slider that supports Microsoft Edge

I am creating a multi range slider, using 2 slider and making them go on top of each other.
I have successfully created it and supported it in Chrome and Mozilla, but I cant seem to support Edge.
The styling is in SCSS.
<!DOCTYPE html>
<html lang="en">
<head>
<style lang="scss">
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.item-value {
display: flex;
position: relative;
width: 100%;
height: 20px;
display: flex;
align-items: center;
&::before {
content: '';
height: 5px;
background: #000;
width: 100%;
background: #ddd;
border-radius: 3px;
}
.min-range, .max-range {
height: 25px;
width: 100%;
margin: 0;
padding: 0;
border: 0;
outline: none;
background: transparent;
-webkit-appearance: none;
-moz-appearance: none;
pointer-events: none; // Prevent mouse interaction on the range slider.
position: absolute;
/* For Webkit Browsers (Chrome) */
&::-webkit-slider-runnable-track {
cursor: default;
height: 5px;
outline: 0;
appearance: none;
background: #ddd;
border-radius: 3px;
position: relative;
}
&::-webkit-slider-thumb {
-webkit-appearance: none;
pointer-events: all;
background: $red;
width: 25px;
height: 25px;
border-radius: 50%;
top: -10px;
position: absolute;
z-index: 10;
cursor: pointer;
}
/* For Mozilla Browsers */
&::-moz-range-track {
opacity: 0;
pointer-events: none;
}
&::-moz-range-thumb {
-webkit-appearance: none;
pointer-events: all;
background: $red;
width: 25px;
height: 25px;
border-radius: 50%;
top: -5px;
position: absolute;
z-index: 10;
cursor: pointer;
border: 0;
}
/* For Edge Browsers */
&::-ms-track {
pointer-events: all;
}
&::-ms-thumb {
border: none;
height: 25px;
width: 25px;
border-radius: 50%;
background: $red;
pointer-events: all;
}
&::-ms-tooltip {
display: none;
pointer-events: all;
}
}
}
}
</style>
</head>
<body>
<section class="item-value">
<input type="range" value="10" class="min-range">
<input type="range" value="10" class="max-range">
</section>
</body>
</html>
In the &::-ms-thumb {}, the pointer-events: all; does not work,
I expect it to re-enable pointer events so the handles can be used again, which happens with &::-webkit-slider-thumb {} and &::-moz-range-thumb {}
Adding the same html and css code to make it runnable here
<!DOCTYPE html>
<html lang="en">
<head>
<style lang="scss">
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.item-value {
display: flex;
position: relative;
width: 100%;
height: 20px;
display: flex;
align-items: center;
&::before {
content: '';
height: 5px;
background: #000;
width: 100%;
background: #ddd;
border-radius: 3px;
}
.min-range, .max-range {
height: 25px;
width: 100%;
margin: 0;
padding: 0;
border: 0;
outline: none;
background: transparent;
-webkit-appearance: none;
-moz-appearance: none;
pointer-events: none; // Prevent mouse interaction on the range slider.
position: absolute;
/* For Webkit Browsers (Chrome) */
&::-webkit-slider-runnable-track {
cursor: default;
height: 5px;
outline: 0;
appearance: none;
background: #ddd;
border-radius: 3px;
position: relative;
}
&::-webkit-slider-thumb {
-webkit-appearance: none;
pointer-events: all;
background: $red;
width: 25px;
height: 25px;
border-radius: 50%;
top: -10px;
position: absolute;
z-index: 10;
cursor: pointer;
}
/* For Mozilla Browsers */
&::-moz-range-track {
opacity: 0;
pointer-events: none;
}
&::-moz-range-thumb {
-webkit-appearance: none;
pointer-events: all;
background: $red;
width: 25px;
height: 25px;
border-radius: 50%;
top: -5px;
position: absolute;
z-index: 10;
cursor: pointer;
border: 0;
}
/* For Edge Browsers */
&::-ms-track {
pointer-events: all;
}
&::-ms-thumb {
border: none;
height: 25px;
width: 25px;
border-radius: 50%;
background: $red;
pointer-events: all;
}
&::-ms-tooltip {
display: none;
pointer-events: all;
}
}
}
}
</style>
</head>
<body>
<section class="item-value">
<input type="range" value="10" class="min-range">
<input type="range" value="10" class="max-range">
</section>
</body>
</html>

(HTML & CSS) How to hide checkbox while still being able to check image

I've been creating a checkbox that has a custom background image. I want to hide the checkbox, but whenever I do I am unable to check it.
HTML:
<div class="arrow">
<label for="togglearrow"></label>
<input type='checkbox' id="togglearrow"/>
<div class="arrowmenu"></div>
</div>
CSS:
#togglearrow {
display: none;
cursor: pointer;
}
.arrow {
position: absolute;
display: block;
background: url('arrow.png') no-repeat;
background-size: 65%;
height: 35px;
bottom: 0;
}
.arrowmenu {
position: absolute;
background: url('test.png') no-repeat;
background-size: 65%;
height: 35px;
bottom: 0;
right: 20px;
}
label[for="togglearrow"] {
display: block;
cursor: pointer;
}
#togglearrow:checked + .arrowmenu {
display: block;
bottom: 0;
left: 50px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
I expect that the checkbox will be hidden and can still click on "tasks.png" to check the box, however, it results in the checkbox not being able to be checked.
Your <label> element doesn't have any dimensions.
Also, I am unsure which element tasks.png is referring to.
#togglearrow {
display: none;
}
.arrow {
position: relative;
display: block;
background: url('https://unsplash.it/100') no-repeat;
background-size: 65%;
height: 35px;
bottom: 0;
}
.arrowmenu {
position: absolute;
background: url('https://unsplash.it/300') no-repeat;
background-size: 65%;
height: 35px;
bottom: 0;
right: 20px;
}
label[for="togglearrow"] {
display: block;
cursor: pointer;
width: 40px;
height: 100%;
border: 1px solid yellow;
}
#togglearrow:checked + .arrowmenu {
display: block;
bottom: 0;
left: 50px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
<div class="arrow">
<label for="togglearrow"></label>
<input type='checkbox' id="togglearrow"/>
<div class="arrowmenu"></div>
</div>

css pseudo element wont show

I am making a navigation menu (following a tutorial), and to make the nav-icon I apparently have to use pseudo elements. Normally that would be fine, but this time, they wont show at all...
Is there something wrong with my code/is there a better way to make the icon?
*,
*::before,
*::after {
box-sizing: inherit;
padding: 0;
margin: 0;
}
body {
padding: 0;
margin: 0;
background-color: #FFF
-webkit-font-smoothing: antialiased;
}
a {
color: hsla(37, 39%, 72%, 1.00);
text-decoration: none;
}
li{
list-style: none;
}
.header {
width: 100vw;
height: 100vh;
display: block;
background:url(img/background.jpg) no-repeat center center;
background-size: cover;
position: relative;
}
.logo {
font-size: 4em;
color: #FFF;
line-height: 1.1;
border: 1px solid #fff;
border-radius: 100%;
width: 80px;
height: 80px;
display: inline-block;
padding: 5px;
background-color: hsla(152, 40%, 20%, 1.00);
margin: 50px 0 0 50px;
cursor: pointer;
}
.nav-icon {
width: 50px;
height: 40px;
display: block;
background-color: transparent;
position: absolute;
top: 70px;
right: 50px;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
}
.nav-icon .icon {
width: 50px;
height: 2px;
display: block;
background-color: #333;
position: absolute;
top: 20px;
}
.nav-icon .icon::before
.nav-icon .icon::after {
content: "";
width: 50px;
height: 2px;
display: block;
background-color: #FFF
position: absolute;
height: 100%;
}
.nav-icon .icon::before {
top: -10px;
}
.nav-icon .icon::after {
top: 10px;
}
You have missed semicolon ; in some lines and comma , in
.nav-icon .icon::before ,
.nav-icon .icon::after {
content: "";
width: 50px;
height: 2px;
display: block;
background-color: #FFF
position: absolute;
height: 100%;
}
that fixes what u were looking for

How can I delete these arrows?

I have this site:
http://test2.dac-proiect.ro/wp/?page_id=6
I want to remove the arrows in the picture below.
http://i61.tinypic.com/rhvgxh.png
You must add the product to cart to see those arrows
Code HTML:
<div class="cart-number">
<span></span>
<div class="quantity buttons_added"><input type="button" value="-" class="minus"><input type="number" step="1" name="cart[d3d9446802a44259755d38e6d163e820][qty]" value="1" title="Quantity" class="input-text qty text" size="4"><input type="button" value="+" class="plus"></div>
</div>
Code CSS:
.quantity {
width: auto;
position: relative;
margin: 0 auto;
overflow: hidden;
zoom: 1;
}
.quantity input.qty {
float: left;
width: 45px;
height: 38px;
text-align: center;
border-bottom-right-radius: 0;
border-top-right-radius: 0;
border-bottom-left-radius: 0;
border-top-left-radius: 0;
padding: 0;
font-weight: bold;
-moz-appearance: textfield;
}
.quantity input.qty:focus:focus {
border-color: #66afe9;
outline: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.quantity .plus, .quantity .minus {
background: #fff;
float: left;
display: block;
padding: 0;
margin: 0;
vertical-align: text-top;
text-decoration: none;
overflow: visible;
text-decoration: none;
cursor: pointer;
line-height: 13px;
font-size: 12px;
color: #666666;
border: 1px solid #e5e5e5;
text-align: center;
width: 45px;
height: 38px;
}
.quantity .plus {
border-left: none;
top: 0;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
right: 0;
}
.quantity .minus {
border-right: none;
bottom: 0;
right: 0;
border-top-right-radius: 0;
border-top-left-radius: 0;
}
How can I solve this problem?
I can not figure out where they come from those arrows
Thanks in advance!
It all depends on the input type, you want to use this bit of CSS to hide it.
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;}
input[type="number"] {
-moz-appearance: textfield;}
Cheers