I am trying to style the up and down button of the input field number on FF. I have successfully achieved this on chrome with the below code but I can't find any CSS trick to do it on FF.
I can't use JS to do this.
Is it possible to style the up and down using CSS in FF? if so how? - I only need to achieve this on the latest version
DOM
<div class="productQty">
<span></span>
<input type="number" max="10" min="1" class="mod"/>
</div>
CSS
input[type="number"] {
height: 30px;
width: 60px;
font-size: 18px;
position: relative;
background-color: transparent;
border: none;
-moz-appearance: textfield;
}
.productQty span {
display: block;
width: 41px;
height: 30px;
background: white;
z-index: -1;
position: absolute;
top: 0;
left: 0;
bottom: 0;
border: solid 1px #999999;
}
/* Spin Buttons modified */
input[type="number"].mod::-webkit-outer-spin-button,
input[type="number"].mod::-webkit-inner-spin-button {
-webkit-appearance: none;
background: transparent url("../img/updown.png") no-repeat center center;
width: 16px;
height: 100%;
opacity: 1; /* shows Spin Buttons per default (Chrome >= 39) */
position: absolute;
top: 0;
right: 0;
bottom: 0;
}
input[type="number"].mod::-moz-inner-spin-button:hover,
input[type="number"].mod::-moz-inner-spin-button:active{
border: none;
}
/* Override browser form filling */
input:-webkit-autofill {
background: black;
color: red;
}
How does it look on chrome and how it should look
How does it looks in FF 38
You can't directly apply css to the buttons on FF, there is a bugreport about it:
https://bugzilla.mozilla.org/show_bug.cgi?id=1108469
If you don't mind to apply some css to the containing element, you could use the :before and :after to overlay custom buttons.
div:before, div:after {
display: block;
position: absolute;
width: 14px;
height: 8px;
line-height: 8px;
background-color: #ccc;
left: 136px;
z-index: 1;
font-size: 9px;
text-align: center;
pointer-events: none;
}
div:before {
content: "+";
top: 11px;
}
div:after {
content: "-";
top: 20px;
}
<div><input type="number" /></div>
Related
I'm trying to use radio buttons styled like a fancy select dropdown—purely with CSS. It seems to work in every browser except Safari. I'm not sure how or why this code I found online works at all, nor do I have a clue why it won't work with Safari on macOS. The problem is that the expanded list doesn't collapse after selecting an option, in Safari. Pretty interesting stuff.
Any suggestions on how to get it working in Safari...or on any other improvements would be appreciated.
div.select {
display: flex;
flex-direction: column;
position: relative;
width: 350px;
height: 40px;
}
div.select label {
order: 2;
border-top: #222 solid 1px;
background-color: #E5E5E5;
display: flex;
align-items: center;
position: absolute;
top: 0;
padding: 0 30px 0 10px;
width: 100%;
min-height: 40px;
pointer-events: none;
box-sizing: border-box;
overflow: hidden;
white-space: nowrap;
z-index: 1;
}
div.select label:hover {
background-color: #FF595C;
}
div.select:focus label {
position: relative;
pointer-events: all;
}
input {
opacity: 0;
position: absolute;
left: -99999px;
}
input:checked+label {
order: 1;
border-top: none;
background-color: #FF595C;
color: white;
position: relative;
z-index: 2;
}
input:checked+label:before {
content: '';
background-color: #050505;
position: absolute;
right: 0;
height: 40px;
width: 40px;
}
input:checked+label:after {
content: '';
background-color: #fff;
position: absolute;
top: 17px;
right: 14px;
width: 0.8em;
height: 0.5em;
clip-path: polygon(100% 0%, 0 0%, 50% 100%);
z-index: 3;
}
<div class="select" tabindex="1">
<input name="career" type="radio" id="c1" checked><label for="c1">Web Design</label>
<input name="career" type="radio" id="c2"><label for="c2">Web Development</label>
<input name="career" type="radio" id="c3"><label for="c3">SEO</label>
<input name="career" type="radio" id="c4"><label for="c4">UI / UX Designer</label>
</div>
There are some CSS codes that doesn't work on safari, especially the old versions. People uses -webkit or -ms in front of their css property to make them work on older version of safari and other browsers.
I'm working on a project and I use an accordion that I made with this website: https://accordionslider.com/
It works perfectly on Chrome but not on Firefox and edge, when I use my custom one I just have a gap between my navbar and the rest of my content. When I use the default one of the website I have a thin line in the middle of where it should be. You can test with the HTML/CSS of the website I provide
For information:
Mozilla Firefox : 73.0
Google Chrome : 80.0
Microsoft Edge : 44
And I'm working with Angular but I don't think it have any impact since it's a CSS/HTML problem
.accordion {
box-sizing: border-box;
display: flex;
font-family: Arial, Helvetica, sans-serif;
overflow: hidden;
width: 100%;
}
.accordion-select {
cursor: pointer;
margin: 0;
opacity: 0;
z-index: 1;
}
.accordion-title {
position: relative;
}
.accordion-title:not(:nth-last-child(2))::after {
border: 1px solid transparent;
bottom: 0;
content: '';
left: 0;
position: absolute;
right: 0;
top: 0;
}
.accordion-title span {
bottom: 0px;
box-sizing: border-box;
display: block;
position: absolute;
white-space: nowrap;
width: 100%;
}
.accordion-content {
box-sizing: border-box;
overflow: auto;
position: relative;
transition: margin 0.3s ease 0.1s;
}
.accordion-select:checked+.accordion-title+.accordion-content {
margin-bottom: 0;
margin-right: 0;
}
/* Generated styles starts here */
.accordion {
border-color: #dedede;
border-radius: 8px;
border-style: solid;
border-width: 1px;
flex-direction: column;
height: auto;
}
.accordion-title,
.accordion-select {
background-color: #ffffff;
color: #7f8787;
width: 100%;
height: 65px;
font-size: 15px;
}
.accordion-select {
margin-bottom: -65px;
margin-right: 0;
}
.accordion-title:not(:nth-last-child(2))::after {
border-bottom-color: rgb(234, 234, 234);
border-right-color: transparent;
}
.accordion-select:hover+.accordion-title,
.accordion-select:checked+.accordion-title {
background-color: #ffffff;
}
.accordion-title span {
transform: rotate(0deg);
-ms-writing-mode: lr-tb;
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0);
padding-left: 33px;
padding-right: 33px;
line-height: 65px;
}
.accordion-content {
background-color: #f7f7f7;
color: #7f8787;
height: 280px;
margin-bottom: -280px;
margin-right: 0;
padding: 30px;
width: 100%;
}
<div class="accordion">
<input type="radio" name="select" class="accordion-select" checked />
<div class="accordion-title"><span>Title</span></div>
<div class="accordion-content">Content</div>
<input type="radio" name="select" class="accordion-select" />
<div class="accordion-title"><span>Title</span></div>
<div class="accordion-content">Content</div>
<input type="radio" name="select" class="accordion-select" />
<div class="accordion-title"><span>Title</span></div>
<div class="accordion-content">Content</div>
</div>
I tested your code with MS Edge, Google Chrome and Firefox browsers. Based on my testing results, I found that all 3 browsers are showing similar output. I am not able to find any difference or issue in output.
Here is my testing result:
If you are still facing the issue then I suggest you try to provide more information about it. We will again try to check for the issue.
I have a range slider on my web which is working fine on all browser other than IE. I am using background image for thumb but that image is not showing on IE and also i am using pseudo element to show starting and ending point, which is also not visible on IE. Here is my code
<input type="range" data-link="test" class="range-slider__range" min="500" step="500" max="10000">
input.range-slider__range {
-webkit-appearance: none;
max-width:100%;
height: 2px;
border:1px solid #06C3C3 !important;
outline: none;
padding: 0;
margin: 50px 0;}
input.range-slider__range:before {
content: '';
width: 7px;
height: 7px;
position: relative;
display: block;
top: -3px;
left: -2px;
border-radius: 50%;
background: #06C3C3;}
input.range-slider__range:after {
content: '';
width: 7px;
height: 7px;
position: relative;
display: block;
top: -3px;
left: 2px;
border-radius: 50%;
background: #06C3C3;}
.range-slider__range::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
background: url("https://dummyimage.com/40/000/fff.jpg");
width: 186px;
height: 49px;
background-repeat: no-repeat;
cursor: pointer;}
.range-slider__range::-moz-range-thumb {
-webkit-appearance: none;
appearance: none;
background: url("https://dummyimage.com/40/000/fff.jpg");
width: 186px;
height: 49px;
background-repeat: no-repeat;
cursor: pointer;}
You use :-webkit-slider-thumb and ::-moz-range-thumb which, by their name, are properties for webkit browsers like chrome/safari etc. and moz which is for mozilla firefox .
So of course it won't appear on IE. For IE you can use ::-ms-thumb together with ms-track
:after,:before are pseudo-elements that are used to insert content after of the before the content of an element. input elements do not have content. ( just like img or hr etc. ). So the behavior in IE, to NOT display :after or :before on a 'non-content' HTML element.
, is the correct one.
You can wrap your input inside a label and add pseudo-elements to it.
Example below ( for IE )
input[type=range]::-ms-track {
width: 300px;
height: 5px;
}
input[type=range]::-ms-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: goldenrod;
}
label {
position: Relative;
}
label:after,
label:before {
content: '';
width: 7px;
height: 7px;
position: absolute;
display: block;
top: 0;
border-radius: 50%;
background: #06C3C3;
}
label:before {
left: 2px;
}
label:after {
right: 2px;
}
<label>
<input type="range" data-link="test" class="range-slider__range" min="500" step="500" max="10000">
</label>
Here is a fiddle demonstrating my problem: JSFiddle
I'm making a custom drop down (in reality I'm using an icomoon icon instead of the V)... it looks nice, but the ::after for the parent element is blocking the select :(
<div class="select-style">
<select>
<option value="">...</option>
<option value="1365">Some term</option>";
</select>
</div>
CSS
.select-style {
width: 240px;
height: 26px;
border: 0;
padding: 0;
margin: 0;
position: relative;
&::after {
/*content: "\f107";
font-family: "icomoon";*/
content: "V";
font-size: 18px;
position: absolute;
right: 7px;
top: 0;
}
}
select {
width: 100%;
height: 24px;
border: 1px solid rgb(199, 199, 199);
border-radius: 3px;
background-color: transparent;
-webkit-appearance: none;
-moz-appearance: none;
text-indent: 1px;
text-overflow: "";
&::-ms-expand {
display: none;
}
}
I've looked into having JS open the drop down, but found out that doesn't work. I've even tried using z-index to see if that would help... but for some reason the icon gets hidden even though the select has a transparent background.
How can I make it so that the custom icon is visible over the select but does not block my select from being clicked?
Add position:relative and z-index:1 to the select itself
https://jsfiddle.net/hbpqvkqL/
select {
...
position: relative;
z-index: 1;
}
yopu can set the ::after to have z-index: -1;
.select-style {
width: 240px;
height: 26px;
border: 0;
padding: 0;
margin: 0;
position: relative;
&::after {
/*content: "\f107";
font-family: "icomoon";*/
content: "V";
font-size: 18px;
position: absolute;
right: 7px;
top: 0;
z-index: -1;
}
}
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.