Im styling a vertical slider using -moz and -webkit.
With mozilla i declare it vertical using orient="vertical" and all the styling works fine.
With chrome since im using -webkit-appearance: none; for styling i can't use -webkit-appearance: slider-vertical, this forces me to use -webkit-transform: rotate(90deg);
The issue is that in mozilla i can use height to declare the real height of the slider instead by rotating it with chrome i'm forced to use width.
#sens[type=range]{
-webkit-appearance: none;
height: 220px; //in chrome is width since it is rotated
}
How can i solve this?
ok, I think you need something like this.
For first you need to read about ::-webkit-slider-runnable-track and ::webkit-slider-thumb. link1 and link2 very useful properties.
And now you can do that like that:
input[type=range] {
-webkit-appearance: none;
-webkit-transform: rotate(90deg);
margin-top: 50px;
}
input[type=range]::-webkit-slider-runnable-track {
width: 300px;
height: 5px;
background: #ccc;
border: none;
border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: red;
margin-top: -5px;
}
input[type=range]:focus {
outline: none;
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: #ddd;
}
<input type="range" />
Related
I am wanting to get the input fields on Safari on the iPhone to look like this JS FIDDLE. Currently I have tried this, which does not produce what I would like:
.input
{
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
outline: none;
border:none;
border-color: transparent;
border: 0;
outline: 0;
background: transparent;
border-bottom: 1px solid grey;
width: 250px;
}
The fields look like the input in the fiddle on desktop in Safari, just not on the phone.
This answer should be what you're looking for. You can remove the rounded corners with the border-radius property for iOS5+ and -webkit-appearance property for older versions. So your CSS would look like this:
.input {
border: 0;
outline: 0;
background: transparent;
border-bottom: 1px solid grey;
width: 250px;
border-radius: 0;
-webkit-appearance: none;
}
New fiddle: https://jsfiddle.net/ct5s8pr9/
I needed to add -webkit-border-radius:0px;
I'm trying to do some basic styling in an html range input with the follow:
HTML
<input type="range" min="0" value="50" max="100" step="1" />
CSS
input[type=range]::-webkit-slider-thumb {
-webkit-appearance : none;
background : red;
height : 20px;
width : 20px;
}
I also made a Codepen you can look at.
You'll notice that if you comment out the background, height and width styles the thumb does dissapear. So something is working. But with the styles applied I'd expect it to be a 20px X 20px red square. But alas, I just see the default thumb styling.
Please check with the below answer
input[type=range] {
-webkit-appearance: none;
}
input[type=range]::-webkit-slider-runnable-track {
width: 300px;
height: 5px;
background: #ddd;
border: none;
border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: goldenrod;
margin-top: -4px;
}
input[type=range]:focus {
outline: none;
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: #ccc;
}
input[type=range] {
/* fix for FF unable to apply focus style bug */
border: 1px solid white;
/*required for proper track sizing in FF*/
width: 300px;
}
input[type=range]::-moz-range-track {
width: 300px;
height: 5px;
background: #ddd;
border: none;
border-radius: 3px;
}
input[type=range]::-moz-range-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: goldenrod;
}
/*hide the outline behind the border*/
input[type=range]:-moz-focusring {
outline: 1px solid white;
outline-offset: -1px;
}
input[type=range]:focus::-moz-range-track {
background: #ccc;
}
/* for ie */
input[type=range]::-ms-track {
width: 300px;
height: 5px;
/*remove bg colour from the track, we'll use ms-fill-lower and ms-fill-upper instead */
background: transparent;
/*leave room for the larger thumb to overflow with a transparent border */
border-color: transparent;
border-width: 6px 0;
/*remove default tick marks*/
color: transparent;
}
input[type=range]::-ms-fill-lower {
background: #777;
border-radius: 10px;
}
input[type=range]::-ms-fill-upper {
background: #ddd;
border-radius: 10px;
}
input[type=range]::-ms-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: goldenrod;
}
input[type=range]:focus::-ms-fill-lower {
background: #888;
}
input[type=range]:focus::-ms-fill-upper {
background: #ccc;
}
<input type="range" min="0" value="50" max="100" step="1" />
If you are able to edit the track, but NOT the thumb, then be sure that you have -webkit-appearance: none; in these two places to override default behavior.
input[type=range] {
-webkit-appearance: none; <------------------------------------ REQUIRED
}
input[type=range]::-webkit-slider-runnable-track {
background: /* ...change color with background property... */;
/* ...my custom edits...*/
}
input[type=range]:hover::-webkit-slider-runnable-track {
background: /* ...change color with background property... */;
/* ...my custom edits... */
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none; <------------------------------------ REQUIRED
height: /* ..manually set height greater than 0... */ <-------- REQUIRED
width: /* ..manually set width greater than 0... */ <---------- REQUIRED
background: /* ...change color with background property... */;
/* ...my custom edits... */
}
input[type=range]:hover::-webkit-slider-thumb {
background: /* ...change color with background property... */;
/* ...my custom edits... */
}
(Note that this works in Chrome, but you can comma separate other properties like input[type=range]::-moz-range-thumb and input[type=range]::-ms-thumb as needed to account for other browsers)
It would seem the following selector is causing the issue and your styles aren't working because of that, please remove it and the styles will apply:
::-webkit-slider-thumb
Here is an updated Codepen.
Updated Answer
Several styles need to be applied to range inputs in all browsers to override their basic appearance. After declaring the below styles you will be able to style the range toggler.
Please see the below and add it to your code:
input[type=range] {
-webkit-appearance: none; /* Hides the slider so that custom slider can be made */
width: 100%; /* Specific width is required for Firefox. */
background: transparent; /* Otherwise white in Chrome */
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
}
input[type=range]:focus {
outline: none; /* Removes the blue border. You should probably do some kind of focus styling for accessibility reasons though. */
}
input[type=range]::-ms-track {
width: 100%;
cursor: pointer;
/* Hides the slider so custom styles can be added */
background: transparent;
border-color: transparent;
color: transparent;
}
Please see this link to the updated Codepen.
So the issue why the styles didn't get applied to the thumb is that you also have to add
input[type=range] {
-webkit-appearance: none;
}
.. The thumb is now a red square.
Hide the input - this hides thumb and track
Style the thumb as you'd like
Style the track
caveat: the track aligns with the top of the thumb. I used a negative margin to correct this. If someone has a better way of doing this that would be nice...
input[type=range] {
-webkit-appearance: none;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
background: red;
height: 20px;
width: 20px;
margin-top: -8px;
}
input[type=range]::-webkit-slider-runnable-track {
width: 300px;
height: 5px;
background: #ddd;
}
<input type="range" min="0" value="50" max="100" step="1" />
CODEPEN
Good resource here for ensuring browser compatibility.
How can I avoid that there is a dotted selection rectangle around the text when the user clicks the button, see image below. I already tried to add the css rule user-select: none;, which I saw in another question, but this doesn't seem to work.
Any suggestions?
EDIT: The issue only appears in Firefox (tested with version 47.0)
.button {
background-color: #1a1a1a;
border: none;
color: #f8f8f8;
padding: 10px 40px;
text-align: center;
display: inline-block;
font-size: 16px;
border-radius: 4px;
user-select: none;
-webkit-transition-duration: 0.3s;/* Safari */
transition-duration: 0.3s;
}
.button:hover {
background-color: #595959;
/* Green */
color: white;
}
<button class="button">Button</button>
For remove the dotted border in buttons in Firefox:
button::-moz-focus-inner {
border: 0;
}
Simply put this in your CSS :
.yourclass
{
outline:none;
}
Hope it helps.
button.button:focus {
outline: 0;
}
i am creating vertical range bar and i changed the -webkit-appearance : slider-vertical.
I also changed the input-range bar's properties such as height , width ,webkit-slider-runnable-track and webkit-slider-thumb properties.
all the input range properties changed except the webkit-slider-thumb. It was set to the default property. I even changed the webkit-appearance to none inside the webkit-slider-thumb.
online code: Jsfiddle
<head>
<style type="text/css">
input[type=range][orient=vertical] {
-webkit-appearance: none;
-webkit-appearance: slider-vertical;/*if we remove this slider-vertical then horizondally range bar styles applies correctly*/
width: 10%;
height: 40%;
}
input[type=range][orient=vertical]::-webkit-slider-runnable-track {
background: yellow;
border: 1px solid black;
}
input[type=range]::-webkit-slider-thumb {
/*all the below css properties **not** applies to thumb*/
height: 3vmin;
width: 3vmin;
border-radius: 50%;
background-color : black;
}
</style>
</head>
<body>
<input type="range" orient="vertical">
</body>
I afraid it's not possible. See [Google chrome vertical <input type="range" /> ] for more info.
But there is a nice trick. https://css-tricks.com/styling-cross-browser-compatible-range-inputs-css/#comment-1586472
input[type=range][orient=vertical] {
-webkit-appearance: none;
/*-webkit-appearance: slider-vertical; /*if we remove this slider-vertical then horizondally range bar styles applies correctly*/
width: 10%;
height: 40%;
transform: translateY(30px) rotate(90deg);
transform-origin:bottom;
}
input[type=range][orient=vertical]::-webkit-slider-runnable-track {
background: yellow;
border: 1px solid black;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: goldenrod;
margin-top: -4px;
}
<input type="range" orient="vertical" />
I have a little issue at the moment, the text placeholder in the textbox doesn't seem to be showing when viewing on IOS device but works fine on desktop and android...
This is just a simple div with an input field in it.
This is the code I am using :
<div id="em_inputs" class="hidden clearfix">
<input type="text" name="first_name" id="first_name" placeholder="First Name">
</div>
#mixin Opacity($value){
$IEValue: $value*100;
opacity: $value;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity="+$IEValue+")";
filter: alpha(opacity=$IEValue);
}
#em_inputs{
-webkit-appearance: none;
-webkit-border-radius:0;
border-radius:0;
overflow: hidden;
position: relative;
top: 127px !important;
width: 100%;
input {
overflow: hidden;
-webkit-appearance: none;
-webkit-border-radius:0;
border-radius:0;
border: none;
width: 100%;
padding: 12px 5px 11px 10px;
color: $text-white;
background: url("../img/bg_input.png") repeat 0 0;
margin: 10px 0 0 0;
#include Opacity(0);
position: relative;
top: -10px;
height: 3px;
overflow: hidden;
&:focus{
border: 2px solid $text-white;
}
}
I am also using this code that makes the placeholder text white color in case a browser uses special rules.
::-webkit-input-placeholder {
color: white;
}
:-moz-placeholder { /* Firefox 18- */
color: white;
}
::-moz-placeholder { /* Firefox 19+ */
color: white;
}
:-ms-input-placeholder {
color: white;
}
::-webkit-scrollbar {
display: none;
}
Does someone have any idea what I going on ? I am not only interested in getting the code fixed but also know if someone experienced the same issues with IOS placeholders in general being a bit picky ?
Could it be because of the background image too ?
I found answers.
The text of the placeholder appears when changing the orientation of the device. That is changing the float.
What I do is just before the page fully loads I do a reset of the float and it works.
This is the source that helped me out.
http://www.456bereastreet.com/archive/201301/the_mysterious_webkit_placeholder_overflow_bug/