Why this Custom Input file is not working in Edge? - html

Hell, I am building a customized input file, it's working on Chrome, FF, Safari, but not on Edge, any idea?
Here's my demo. Please open it on Chrome then on Edge to understand the issue:
/* /////////////////Custom Upload input///////////// */
.custom-file-input::-webkit-file-upload-button {
visibility: hidden;
-webkit-appearance: none;
}
.custom-file-input::-ms-file-upload-button {
visibility: hidden;
-ms-appearance: none;
}
.custom-file-input::before {
content: 'Attach';
display: inline-block;
background-color: #c6c6c6;
border: none;
width: 50px;
font-family: Roboto, sans-serif, FontAwesome;
border-radius: 3px;
padding: 5px 8px;
outline: none;
white-space: nowrap;
-webkit-user-select: none;
font-weight: normal;
font-style: normal;
font-stretch: normal;
cursor: pointer;
color: #ffffff;
font-size: 12px;
text-align: center;
}
.custom-file-input:hover::before {
border-color: black;
}
.custom-file-input:active::before {
background: -webkit-linear-gradient(top, #e3e3e3, #f9f9f9);
}
<input class="custom-file-input" type="file">

You should use ::-ms-browse to style the file input button in Edge. Then we must wrap input type file with label and do something in CSS. And if you want to change the default file input box in Edge, you need to hide it first using input[type="file"] { opacity: 0;} and combine js code to show the file name. You could check my sample of styling input type file in Edge and Chrome below:
$('input[type=file]').change(function(e) {
$in = $(this);
$in.next().html($in.val());
});
.custom-file-input::-webkit-file-upload-button {
visibility: hidden;
-webkit-appearance: none;
}
::-ms-browse {
display:none;
}
input[type="file"] {
display: input-block;
width: 100%;
height: 30px;
opacity: 0;
cursor:pointer;
position:absolute;
left:0;
}
.custom-file-input::before {
content: 'Attach';
display: inline-block;
background-color: #c6c6c6;
border: none;
width: 50px;
font-family: Roboto, sans-serif, FontAwesome;
border-radius: 3px;
padding: 5px 8px;
outline: none;
white-space: nowrap;
-webkit-user-select: none;
font-weight: normal;
font-style: normal;
font-stretch: normal;
cursor: pointer;
color: #ffffff;
font-size: 12px;
text-align: center;
}
.custom-file-input:hover::before {
border-color: black;
}
.custom-file-input:active::before {
background: linear-gradient(top, #e3e3e3, #f9f9f9);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<label class="custom-file-input">
<input type="file">
<span class="fileName">Choose file...</span>
</label>

Related

Input field placeholder not visible on Ios safari

Here is my code for input field and placeholder. Don't know why its not working on ios safari but the same is working on other devices.
.form input {
margin-top: 30px;
border: 1px solid #d8d8d8;
border-radius: 5px;
background-color: transparent;
outline: none;
width: 50%;
/* padding: 18px 15px;
font-size: 14px; */
line-height: 40px;
height: 50px;
padding: 0 15px;
font-family: "Campan";
color: #3d8559;
position: relative;
}
.form input::placeholder {
font-size: 14px;
transition: 400ms;
position: absolute;
top: 32%;
left: 10px;
color: #8e8e8e;
}
I have also tried the code below but not working
::-webkit-input-placeholder {
color: #000;
opacity: 1;
}
::-moz-placeholder {
/* Firefox 19+ */
color: #777;
}
:-ms-input-placeholder {
color: #777;
}
:-moz-placeholder {
/* Firefox 18- */
color: #777;
}

How can I remove this white background or border from my Font Awesome checkbox?

I am using Font Awesome 5 to style my checkbox my problem is when I click on my checkbox there is a white background or border that I can't remove or hide
/* Update default snippet color to better see the problem */
body {
background-color: black;
color: white;
}
input[type=checkbox], input[type=radio] {
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
outline: 0;
font-family: "Font Awesome 5 Free";
font-weight: 700;
font-size: 16px;
line-height: 14px;
}
input[type=checkbox]:after, input[type=radio]:after {
content: "\f0c8";
color: #ffffff;
display: block;
border-radius: 0px;
}
input[type=checkbox]:checked:before {
position: absolute;
content: "\f14a";
color: #445867;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.1.0/css/all.css" rel="stylesheet"/>
<div id='test'>
<input type="checkbox" name="cbx">
<label for="cbx">my checkbox</label>
</div>
and the JSFiddle to test: https://jsfiddle.net/fyc4bwmr/1/
Change input[type=checkbox]:checked:before to input[type=checkbox]:checked:after and remove position: absolutefrom that declaration block:
input[type=checkbox]:checked:after{
content: "\f14a";
color: #445867;
}
Fiddle:
/* NEW CSS */
input[type=checkbox]:checked:after {
content: "\f14a";
color: #445867;
}
/* Update default snippet color to better see the problem */
body {
background-color: black;
color: white;
}
input[type=checkbox],
input[type=radio] {
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
outline: 0;
font-family: "Font Awesome 5 Free";
font-weight: 700;
font-size: 16px;
line-height: 14px;
}
input[type=checkbox]:after,
input[type=radio]:after {
content: "\f0c8";
color: #ffffff;
display: block;
border-radius: 0px;
}
/* Remove */
/* input[type=checkbox]:checked:before {
position: absolute;
content: "\f14a";
color: #445867;
}*/
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.1.0/css/all.css" rel="stylesheet" />
<div id='test'>
<input type="checkbox" name="cbx">
<label for="cbx">my checkbox</label>
</div>

Custom Checkbox Issue in only Edge

I am facing a strange problem with a checkbox that I have customized for my personal blog. I was checking for browser compatibility when I found this scenario.
The custom checkbox is working in Chrome, Firefox and IE 10. But when I checked for Edge, it is not working and the styles are not getting applied.
label {
display: inline-block;
max-width: 100%;
}
input[type='checkbox'] {
display: none;
box-sizing: border-box;
padding: 0;
outline: none;
border: none;
background: transparent;
width: auto;
}
input[type='checkbox']:checked+.tick_mark {
color: #16a0de;
}
input[type='checkbox']+span {
cursor: pointer;
font-weight: normal;
font-size: 11px;
}
.tick_mark {
border: 1px solid #666;
padding: 0px 1px;
color: white;
margin: 6px 4px 6px 0;
font-weight: normal;
}
<label>
<input name="postSelected" class="NonUnSaved" id="chkBlog" type="checkbox" value="4">
<span class="tick_mark">✔</span>
<span class="btntooltip" data-val="checkboxTest">Text 1</span>
</label>
Why this is happening
Edge is defaulting to the Segoe UI Emoji font for the emoji instead of Segoe UI Symbol.
How to fix it
To get a consistent result add font-family: Segoe UI Symbol; to .tick_mark.
label {
display: inline-block;
max-width: 100%;
}
input[type='checkbox'] {
display: none;
box-sizing: border-box;
padding: 0;
outline: none;
border: none;
background: transparent;
width: auto;
}
input[type='checkbox']:checked+.tick_mark {
color: #16a0de;
}
input[type='checkbox']+span {
cursor: pointer;
font-weight: normal;
font-size: 11px;
}
.tick_mark {
border: 1px solid #666;
color: white;
margin: 6px 4px 6px 0;
font-weight: normal;
font-family: Segoe UI Symbol;
line-height: 1em;
min-width: 1em;
min-height: 1em;
display: inline-block;
text-align: center;
}
<label>
<input name="postSelected" class="NonUnSaved" id="chkBlog" type="checkbox" value="4">
<span class="tick_mark">✔</span>
<span class="btntooltip" data-val="checkboxTest">Text 1</span>
</label>

Radio buttons and checkboxes not appearing

I am trying to launch a Web UI using Flask, however, the radio buttons and check boxes aren't showing. I've tried following online examples, like the ones here: https://www.w3schools.com/bootstrap/bootstrap_forms_inputs.asp
The CSS file has a lot of sections pertaining to checkboxes/radios, but I'm not sure which part is the source of the problem (if that).
Here is the relevant portion of the CSS file:
/* Form */
form {
margin: 0 0 2em 0;
}
label {
display: block;
font-size: 0.9em;
font-weight: 400;
margin: 0 0 1em 0;
}
input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
-moz-appearance: none;
-webkit-appearance: none;
-ms-appearance: none;
appearance: none;
border-radius: 4px;
border: none;
border: solid 1px;
color: inherit;
display: block;
outline: 0;
padding: 0 1em;
text-decoration: none;
width: 100%;
}
input[type="text"]:invalid,
input[type="password"]:invalid,
input[type="email"]:invalid,
select:invalid,
textarea:invalid {
box-shadow: none;
}
.select-wrapper {
text-decoration: none;
display: block;
position: relative;
}
.select-wrapper:before {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
text-transform: none !important;
}
.select-wrapper:before {
content: '\f078';
display: block;
height: 2.75em;
line-height: 2.75em;
pointer-events: none;
position: absolute;
right: 0;
text-align: center;
top: 0;
width: 2.75em;
}
.select-wrapper select::-ms-expand {
display: none;
}
input[type="text"],
input[type="password"],
input[type="email"],
select {
height: 2.75em;
}
textarea {
padding: 0.75em 1em;
}
input[type="checkbox"],
input[type="radio"] {
-moz-appearance: none;
-webkit-appearance: none;
-ms-appearance: none;
appearance: none;
display: block;
float: left;
margin-right: -2em;
opacity: 0;
width: 1em;
z-index: -1;
}
input[type="checkbox"]+label,
input[type="radio"]+label {
text-decoration: none;
cursor: pointer;
display: inline-block;
font-size: 1em;
font-weight: 200;
padding-left: 2.4em;
padding-right: 0.75em;
position: relative;
}
input[type="checkbox"]+label:before,
input[type="radio"]+label:before {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
text-transform: none !important;
}
input[type="checkbox"]+label:before,
input[type="radio"]+label:before {
border-radius: 4px;
border: solid 1px;
content: '';
display: inline-block;
height: 1.65em;
left: 0;
line-height: 1.58125em;
position: absolute;
text-align: center;
top: 0;
width: 1.65em;
}
input[type="checkbox"]:checked+label:before,
input[type="radio"]:checked+label:before {
content: '\f00c';
}
input[type="checkbox"]+label:before {
border-radius: 4px;
}
input[type="radio"]+label:before {
border-radius: 100%;
}
::-webkit-input-placeholder {
opacity: 1.0;
}
:-moz-placeholder {
opacity: 1.0;
}
::-moz-placeholder {
opacity: 1.0;
}
:-ms-input-placeholder {
opacity: 1.0;
}
.formerize-placeholder {
opacity: 1.0;
}
label {
color: #444444;
}
input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
background: rgba(144, 144, 144, 0.075);
border-color: #666666;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
border-color: #EF6480;
box-shadow: 0 0 0 1px #EF6480;
}
.select-wrapper:before {
color: #666666;
}
input[type="checkbox"]+label,
input[type="radio"]+label {
color: #666666;
}
input[type="checkbox"]+label:before,
input[type="radio"]+label:before {
background: rgba(144, 144, 144, 0.075);
border-color: #666666;
}
input[type="checkbox"]:checked+label:before,
input[type="radio"]:checked+label:before {
background-color: #EF6480;
border-color: #EF6480;
color: #ffffff;
}
input[type="checkbox"]:focus+label:before,
input[type="radio"]:focus+label:before {
border-color: #EF6480;
box-shadow: 0 0 0 1px #EF6480;
}
::-webkit-input-placeholder {
color: #999999 !important;
}
:-moz-placeholder {
color: #999999 !important;
}
::-moz-placeholder {
color: #999999 !important;
}
:-ms-input-placeholder {
color: #999999 !important;
}
.formerize-placeholder {
color: #999999 !important;
}
Here is the relevant portion of the HTML file:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<!-- Wrapper -->
<div id="wrapper">
<!-- Banner -->
<section id="intro" class="main">
<span class="icon fa-diamond major"></span>
<h3>Please upload your authors list below</h3>
<form action="" method=post enctype=multipart/form-data>
<p><input type=file name=file>
<br><br>
<input type="checkbox" name="sep1" value="Separate initials with period"> Separate initials with period<br>
<input type="checkbox" name="sep2" value="Separate initials with space"> Separate initials with space<br>
<input type="radio" name="affiliation" value="Mark affiliations with letter"> Mark affiliations with letter
<input type="radio" name="affiliation" value="Mark affiliations with number" checked> Mark affiliations with number<br><br>
<input type=submit value=Upload></p>
</form>
</section>
</div>
You can Simplify your CSS from :
input[type="checkbox"], input[type="radio"] {
-moz-appearance: none;
-webkit-appearance: none;
-ms-appearance: none;
appearance: none;
display: block;
float: left;
margin-right: -2em;
opacity: 0;
width: 1em;
z-index: -1;
}
Into This 1
input[type="checkbox"], input[type="radio"] {
width: 1em;
z-index: -1;
}
Or You can just Delete that part of your CSS
Here is the problematic section of your css:
input[type="checkbox"],
input[type="radio"] {
-moz-appearance: none;
-webkit-appearance: none;
-ms-appearance: none;
appearance: none;
display: block;
float: left;
margin-right: -2em;
opacity: 0;
width: 1em;
z-index: -1;
}
Change opacity to 1
Get rid of the appearance none.
There are other problems with your code but this solves your question about the boxes not appearing.
This should get you closer to what you are looking for:
input[type="checkbox"],
input[type="radio"] {
display: inline-block;
opacity: 1;
width: 1em;
z-index: -1;
}
It can happen because of multiple reasons, however
opacity: 1;
is one of the crucial things if your checkbox is not visible. Secondly, your position should not be absolute, it should be like
position: relative;
Just in case you are not able to click/check your checkbox, it's because you have blocked pointer-events. So change it to
pointer-events: all;
In all, your CSS code will look like this,
input[type="checkbox"]{
width: 1em;
position: relative;
opacity: 1;
pointer-events: all;
}
Note: In case if you still fail to achieve the desired result, try this code
input[type="checkbox"]{
width: 1em;
position: relative !important;
opacity: 1 !important;
pointer-events: all !important;
}

:before element not displaying properly in firefox

Why does firefox misplace the :before element??
<div id='remember_forgot' class='no_hl'>
<div>
<input id='remember_me' type='checkbox'>
<label for='remember_me'>Remember me</label>
</div>
</div>
* {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 1.3;
font-weight: normal;
}
input[type='checkbox'] {
display: none;
}
#remember_forgot {
display: flex;
align-items: center;
justify-content: space-between;
margin: 2px 0;
}
#remember_forgot>div {
position: relative;
display: flex;
align-items: center;
}
#remember_me+label:before {
position: relative;
top: 1px;
content: "";
display: block;
float: left;
width: 13px;
height: 13px;
margin-right: 4px;
font-size: 15px;
line-height: 0.8;
border: 1px solid black;
}
#remember_me:checked+label:before {
content:'✓';
color: black;
}
#remember_me+label {
display: inline-block;
margin-left: 0px;
color: black;
font-size: 13px;
}
#remember_me+label:hover {
color: #e1b941;
}
#remember_me,
#remember_me+label,
#forgot {
cursor: pointer;
}
#remember_me+label {
transition: 0.2s all;
}
All of the relevant code is here in the fiddle: http://jsfiddle.net/kjf8h5m6/7/
When I open it in chrome the checkbox :before element is properly centered:
But when it is viewed in firefox the checkbox looks like it is not centered:
This is very annoying.. please help!
(Left is chrome, right is firefox)
Removing the wildcard line-height: *{line-height:1.3;}, and adding a line-height of 1.5 to the label element solves this in both Firefox and Chrome.
Working fix: http://jsfiddle.net/kjf8h5m6/9/