On opera, i can do the following
<style>
#range{
width: 20px;
heigth: 300px;
}
</style>
<input type="range" id="range" />
and it will render a vertical slider. However, this doesn't seem to work on chrome. Is there a way I can do this? (I'm not looking for any jQuery sliders or anything)
It seems Chromium does not yet implement support for this yet:
See: http://www.chromium.org/developers/web-platform-status/forms
Not available yet
Localization of
Dedicated UIs for color, date, datetime, datetime-local, month, time,
and week types
Automatic switching to vertical range
Value sanitization algorithms
datalist element, list attribute, and list/selectedOption properties
Edit: Vuurwerk indicated that it is actually possible to alter the presentation using the -webkit-appearance: slider-vertical property. Although this does transform it into a vertical slider, I would not recommend doing this, since it will break your layout and doesn't look really pretty: example.
If you really want a vertical slider, use a JavaScript solution. Support for <input type="range" /> is very basic at the moment anyway, so you are probably better off with a graceful degradation or progressive enhancement approach.
-webkit-appearance: slider-vertical;
Maybe with a css transform ?
-webkit-transform: rotate(90);
Another solution could be to use the slider module from jQuery UI.
http://jqueryui.com/demos/slider/#slider-vertical
input[type='range']{
width:20px;
height:140px;
border:2px solid blue;
display:block;
-webkit-transform:rotate(90deg); /* Safari and Chrome */
-moz-transform:rotate(90deg);
-o-transform:rotate(90deg);
-ms-transform:rotate(90deg);
transform:rotate(90deg);
z-index: 0;
}
As Aron has said there is no support for webkit browser.
However this is what i could do for achieving the output.
body {
margin: 50px;
}
.opacitySlider {
position: relative;
transform: rotate(90deg);
width: 125px;
height: 20px;
}
.opacitySlider:before {
content: " ";
left: 10px;
top: 1px;
position: absolute;
border-top: 9px solid transparent;
border-bottom: 9px solid transparent;
border-left: 115px solid #ccc;
}
.opacitySlider input[type=range] {
outline: none;
-webkit-appearance: none;
height: 20px;
padding: 0;
width: 125px;
background: transparent;
position: relative;
margin: 0;
cursor: pointer;
}
.opacitySlider input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
background: #69a80e;
height: 20px;
width: 20px;
border: 1px solid #fff;
border-radius: 50%;
}
.opacitySlider input[type=range]::-moz-range-track {
border: none;
background-color: transparent;
}
.opacitySlider input[type=range]::-moz-range-thumb {
background: #69a80e;
height: 20px;
width: 20px;
border: 1px solid #fff;
border-radius: 50%;
}
.opacitySlider input[type=range]::-ms-fill-lower, .opacitySlider input[type=range]::-ms-fill-upper {
background: transparent;
}
.opacitySlider input[type=range]::-ms-track {
height: 18px;
border: none;
background-color: transparent;
margin: 0;
}
.opacitySlider input[type=range]::-ms-thumb {
background: #69a80e;
height: 20px;
width: 20px;
border: 1px solid #fff;
border-radius: 50%;
height: 17px;
width: 17px;
}
<div class="opacitySlider">
<input step="any" type="range">
</div>
Related
I've spent hours looking at similar problems and nothing I try changes the fill color for the selected range in Chrome. Changing color in -webkit-progress-value and -webkit-progress-bar does nothing. I've also tried some Vanilla JS as well, but that didn't work either.
I might have looked myself blind on this problem. What am I missing?
PS. I'm not able to get my code working here at Stack (sorry), but I have a working example in Code Pen
input[type="range"] {
margin: 0;
padding: 0;
border: 0;
outline: none;
background: transparent;
width: 100%;
height: 22px;
border-radius: 3px;
-webkit-appearance: none; // Chrome reset
}
input[type="range"]::-webkit-slider-runnable-track {
height: 3px;
border-radius: 2px;
background-color: #434b52;
transition: all .2s ease;
}
input[type="range"]::-webkit-progress-value {
background-color: #ff0000; // red
}
input[type="range"]::-webkit-progress-bar {
background-color: #00ff00; // Green
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none; // Chrome reset
box-sizing: border-box;
height: 16px;
width: 16px;
border-radius: 50%;
border: solid 2px #2bdeee;
background-color: #25bbc8;
cursor: pointer;
margin-top: -7px;
}
.kx-range {
padding: 4px 8px;
}
html {
background-color: #262a2f;
margin-top: 50px;
}
<div class="kx-range">
<input id="ranger" type="range" min="0" max="1000" value="250" step="1">
</div>
I want to know how to customize the arrows of a spin box.
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
-webkit-appearance: inner-spin-button !important;
opacity: 1 !important;
}
<input type="number" />
This is what I want to get.
Where should I start??
(Do I have to use jQuery widget or javascript to customize it?)
Screenshot (Chrome, macOS):
Code:
input[type="number"] {
height: 32px;
border-radius: 4px;
border: 1px solid #d8d8d8;
position: relative;
text-align: center;
font-size: 20px;
width: 80px;
outline: none;
background-image: url('data:image/svg+xml;utf8,%3Csvg%20version%3D%221.1%22%20viewBox%3D%220%200%2050%2067%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20stroke-width%3D%222%22%3E%3Cline%20x1%3D%221%22%20x2%3D%2250%22%20y1%3D%2233.5%22%20y2%3D%2233.5%22%20stroke%3D%22%23D8D8D8%22%2F%3E%3Cpolyline%20transform%3D%22translate(25%2020)%20rotate(45)%20translate(-25%20-20)%22%20points%3D%2219%2026%2019%2014%2032%2014%22%20stroke%3D%22%23000%22%2F%3E%3Cpolyline%20transform%3D%22translate(25%2045)%20rotate(225)%20translate(-25%20-45)%22%20points%3D%2219%2052%2019%2039%2032%2039%22%20stroke%3D%22%23000%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E');
background-position: center right;
background-size: contain;
background-repeat: no-repeat;
caret-color: transparent;
}
input[type="number"]::-webkit-inner-spin-button {
-webkit-appearance: none !important;
opacity: 1 !important;
background: transparent !important;
border-width: 0px;
margin: 0;
border-left: 1px solid #d8d8d8;
height: 34px;
width: 23px;
cursor: pointer;
}
<input type="number" value="1" />
So, it can be done. But customizations like this are usually very brittle (even if you add in the necessary cross-browser properties, which I haven't done; this only works in webkit), and can hurt usability. You're probably better off using the platform's native controls.
My answer try of fix your problem with css pure, for example with input[type=number] {} you can put all of rules to change the look of the input
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
-webkit-appearance: inner-spin-button !important;
opacity: 1 !important;
width: 50px;
position: absolute;
top: 0;
right: 0;
height: 100%;
background-color: blue !important;
border: 2.5px solid red !important;
}
input[type=number] {
position: relative;
padding: 5px;
width: 50px;
padding-right: 25px;
height: 30px;
text-align: center;
font-family: sans-serif;
font-size: 2rem;
border: 1px solid #9c9c9c !important;
border-radius: 0.2em;
}
<input type="number" />
I am trying to set outline width of the input element on focus.
Outline width stays the same (like it is default setting which can not be changed), no matter of my setting.
Here is example from code pen
And here is part from css where I am trying to set outline-width on focus:
input:focus {
outline-width: 0.1px;
outline-color: #725b44;
}
EDIT:
I've just forgotten to include line style (solid, dotted...).
Now it works. One thing is still strange to me. Why is outline inside element?
Isnt' the outline defined as 'a line that is drawn around elements (outside the borders) to make the element "stand out".'
Here from my example outline looks like this. I thought it's going to be around element, but it's inside:
Add outline-style: solid to your css.
Since the default style for the outline-style property is none, you will have to set it as well (none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|initial|inherit). Best value you can use for the style is solid, but that's a matter of preference.
Example for the behavior:
input {
font-size: 22px;
padding: 5px 3px;
color: #666;
}
input.with-outline-style:focus {
outline-width: 3px;
outline-style: solid;
outline-color: #725b44;
/* You could also use the shorthand: */
/* outline: 3px solid #666; */
/* width style color */
}
input.without-outline-style:focus {
outline-width: 3px;
outline-color: #725b44;
}
body {
background-color: #fd9;
}
div {
padding: 5px 10px;
}
<div>
<input type="text" class="with-outline-style" value="outline-style set to solid" />
</div>
<div>
<input type="text" class="without-outline-style" value="outline-style not set" />
</div>
Update
The outline-width setting doesn't work without specifying outline-style: if no outline style is set, the browser will render the outline in its default style (which could be anything, such as a dotted rectangle in IE, a shaded rectangle in Chrome, or even nothing).
Use outline-style
input:focus {
outline-width: 0.1px;
outline-color: #725b44;
outline-style: dotted;
}
Only if you specify outline-style the outline-width will take effect. Please check and let me know your feedback. Thanks!
snippet below:
.divMain {
height: 100vh;
width: 100vw;
border: 0px solid black;
}
.divLogin {
position: absolute;
left: 20%;
top: 5%;
width: 300px;
height: 600px;
border: 1px solid #CF6B08;
border-radius: 3px;
}
#divLogin {
background: #FFCC99;
/* For browsers that do not support gradients */
background: -webkit-linear-gradient(#FAC28A, #FFCC99);
/* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#FAC28A, #FFCC99);
/* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#FAC28A, #FFCC99);
/* For Firefox 3.6 to 15 */
background: linear-gradient(#FAC28A, #FFCC99);
/* Standard syntax */
}
.spanTitle {
position: absolute;
top: 10px;
left: 10px;
font-size: 20px;
color: #003399;
font-weight: bold;
}
.inputFirst {
position: absolute;
top: 50px;
margin-left: 5px;
width: calc(100% - 10px);
height: 30px;
}
.divWarningInputFirst {
position: absolute;
width: calc(100% - 10px);
height: 30px;
top: 88px;
margin-left: 5px;
border: 0px solid black;
background-color: #fcdcbb;
color: #ff0000;
font-weight: bold;
padding-top: 5px;
padding-left: 5px;
}
.divWarningInputFirst:after {
content: "";
position: absolute;
top: -5px;
left: 8px;
border-style: solid;
border-width: 0 5px 6px;
border-color: #fcdcbb transparent;
display: block;
width: 0;
z-index: 1;
}
input:focus {
outline-width: 3px;
outline-style: solid;
outline-color: #725b44;
}
input {
border-color: transparent;
padding-left: 3px;
box-sizing: border-box;
}
<div id="divMain" class="divMain">
<div id="divLogin" class="divLogin">
<span id="spanTitle" class="spanTitle">Login</span>
<input type="text" id="inputFirst" class="inputFirst" placeholder="input first">
<div id="divWarningInputFirst" class="divWarningInputFirst">Please enter input first</div>
</div>
</div>
Try
outline: 3px solid #725b44;
or
outline-width:3px;
outline-color:#725b44;
outline-style:solid;
.divMain {
height: 100vh;
width: 100vw;
border: 0px solid black;
}
.divLogin {
position: absolute;
left: 20%;
top: 5%;
width: 300px;
height: 600px;
border: 1px solid #CF6B08;
border-radius: 3px;
}
#divLogin {
background: #FFCC99;
/* For browsers that do not support gradients */
background: -webkit-linear-gradient(#FAC28A, #FFCC99);
/* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#FAC28A, #FFCC99);
/* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#FAC28A, #FFCC99);
/* For Firefox 3.6 to 15 */
background: linear-gradient(#FAC28A, #FFCC99);
/* Standard syntax */
}
.spanTitle {
position: absolute;
top: 10px;
left: 10px;
font-size: 20px;
color: #003399;
font-weight: bold;
}
.inputFirst {
position: absolute;
top: 50px;
margin-left: 5px;
width: calc(100% - 10px);
height: 30px;
}
.divWarningInputFirst {
position: absolute;
width: calc(100% - 10px);
height: 30px;
top: 88px;
margin-left: 5px;
border: 0px solid black;
background-color: #fcdcbb;
color: #ff0000;
font-weight: bold;
padding-top: 5px;
padding-left: 5px;
}
.divWarningInputFirst:after {
content: "";
position: absolute;
top: -5px;
left: 8px;
border-style: solid;
border-width: 0 5px 6px;
border-color: #fcdcbb transparent;
display: block;
width: 0;
z-index: 1;
}
input:focus {
outline: 3px solid #725b44;
}
input {
border-color: transparent;
padding-left: 3px;
box-sizing: border-box;
}
<div id="divMain" class="divMain">
<div id="divLogin" class="divLogin">
<span id="spanTitle" class="spanTitle">Login</span>
<input type="text" id="inputFirst" class="inputFirst" placeholder="input first">
<div id="divWarningInputFirst" class="divWarningInputFirst">Please enter input first</div>
</div>
</div>
This might help you!
You should add 1px instead of 0.1px with outline-style
input:focus {
outline:1px solid #725b44;
}
Rather than Is it possible to always show up/down arrows for input "number"?, I want to be able to make up/down arrow much bigger and cleaner.
What I have right now:
I need to make them bigger like this:
you can wrap a input in and element and style it
div {
display: inline-block;
position: Relative;
border: 2px solid grey;
border-radius: 10px;
overflow: hidden;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
div:before,
div:after {
background: white;
right: 0px;
width: 30px;
height: 20%;
position: absolute;
pointer-events: none;
}
div:before {
content: '';
bottom: 50%;
background: url(http://cdn.flaticon.com/png/256/22205.png) no-repeat white;
background-size: 20px;
background-position: center;
}
div:after {
content: '';
top: 50%;
background: url(http://cdn.flaticon.com/png/256/22205.png) no-repeat white;
background-size: 20px;
transform: rotate(180deg);
background-position: center;
}
input {
height: 80PX;
font-size: 50px;
outline: 0;
border: 0;
}
<div>
<input type="number" value="10" />
</div>
well, to achieve that you have to play with pseudo elements and some CSS3 tricks.
to create triangle https://css-tricks.com/snippets/css/css-triangle/
to manipulate input number spinners
input[type=number]::-webkit-inner-spin-button {
/* your code*/
}
here is the example.
input {
color: #777;
width: 2em;
font-size: 2em;
border-radius: 10px;
border: 2px solid #ccc;
padding: 5px;
padding-left: 10px;
}
input[type=number]::-webkit-inner-spin-button {
-webkit-appearance: none;
cursor: pointer;
display: block;
width: 10px;
text-align: center;
position: relative;
background: transparent;
}
input[type=number]::-webkit-inner-spin-button::before,
input[type=number]::-webkit-inner-spin-button::after {
content: "";
position: absolute;
right: 0;
width: 0;
height: 0;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 10px solid #777;
}
input[type=number]::-webkit-inner-spin-button::before {
top: 7px;
}
input[type=number]::-webkit-inner-spin-button::after {
bottom: 7px;
transform: rotate(180deg);
}
<input type="number" value="1">
Another solution, offering uniformity between browsers and more customisation options, would be to use the JQuery UI spinner element.
I am implementing a search box for a html-javascript based app using Chrome:
fiddle
it should look like this:
but when I deploy app on iphone,
screen looks like this:
I know it's difference with webkit, I thought using safari to debug it would be a solution, however,when I use safari to open it, it looks like this:
Just don't know why on iPhone, it looks like that. How to improve it to the feature which I need?
Here is the html:
<div class="form-wrapper">
<input type="text" placeholder="Search here..." required>
<button type="submit">Search</button>
</div>
CSS:
.form-wrapper {
height: 80px;
background: #555;
color: #FFF;
clear: both;
}
.form-wrapper input {
background-color: #FFF;
-moz-box-sizing: border-box;
border-radius: 10px;
border: 5px solid #E5E4E2;
margin: 2px;
height: 40px;
vertical-align: middle;
padding: 20px;
margin-top: 15px;
width: 85%;
}
.form-wrapper button {
overflow: visible;
position: absolute;
float: right;
border: 0;
padding: 0;
cursor: pointer;
height: 40px;
width: 110px;
color: #FFF;
text-transform: uppercase;
background: red;
border-radius: 0 3px 3px 0;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3);
margin: 20px -116px;
}
.form-wrapper button:before {
content:'';
position: absolute;
border-width: 8px 8px 8px 0;
border-style: solid solid solid none;
border-color: transparent red transparent;
top: 12px;
left: -6px;
}
type="search" causes the field to have a -webkit-appearance: searchfield on Safari, which causes lots of your styles to be ignored.
Have either a none appearance or textfield appearance.
Here is a fiddle with none, which seems to work for me on Safari 6/OSX (no iDevice available to test).