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;
}
Related
I have a select with reset style and trying to create additional button and dropdown arrow icon inside using ::after selector and content. And now I'm trying to style the select in case of disabled applied on it. For the button case, I change the style by using select:disabled + button.resetDropdownButton::after. However, I still can't find the way to re-style the arrow icon when select is disabled. Anyone know how to do it?
select, option {
-webkit-appearance: none;
}
button.resetDropdownButton::after {
content: "\2716";
}
.filterWrapper {
/* flex: 1;*/
margin: 0 1rem 1rem;
position: relative;
}
.filterWrapper label {
display: block;
margin-bottom: .25rem;
}
.filterItem {
position: relative;
}
.filterItem::after {
/*add arrow down from fa-icon*/
content: '\f107';
font: normal normal normal 12px/1 FontAwesome;
color: black;
right: 8px;
top: -2px;
height: 26px;
padding: 15px 0px 0px 8px;
position: absolute;
pointer-events: none;
}
.filterItem select {
width: 100%;
/*padding: 0.5rem 1rem;*/
padding-right: 2rem;
padding-left: 1rem;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
font-size: 1rem;
border-radius: 6px;
border: 2px solid #CBD2E0;
transition: .2s all;
cursor: pointer;
}
.filterItem select::-webkit-input-placeholder {
color: var(--grey);
}
.filterItem select:focus {
outline: none;
background-color: rgba(214, 238, 247, 0.5);
border: 1px solid var(--blue);
box-shadow: 0 0 3px var(--blue);
}
.filterItem select > option {
border-radius: 10px;
}
.filterWrapper .resetDropdownButton {
position: absolute;
top: auto;
right: 1.15rem;
bottom: .5rem;
background-color: transparent;
font-family: 'Roboto', sans-serif;
font-size: 1rem;
/* font-weight: bold;*/
border: 0 solid transparent;
cursor: pointer;
}
.filterWrapper .resetDropdownButton:hover {
text-decoration: underline;
}
select:disabled + button.resetDropdownButton::after {
color: gray;
opacity: 0.7;
}
select:disabled + button.resetDropdownButton:hover {
text-decoration: none;
}
select:disabled + filterItem::after {
/*add arrow down from fa-icon*/
color: yellow;
opacity: 0.7;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" rel="stylesheet" />
<div class="filterWrapper">
<div class="filterItem">
<select disabled>
<option>A</option>
<option>B</option>
<option>C</option>
</select>
<button class="resetDropdownButton"></button>
</div>
</div>
I expect the arrow icon that I create using ::after on the div wrapper can be restyle like the button one when select disabled.
Keeping the same HTML structure
This can be achieved with .filterItem:has(select:disabled)::after. But selector :has() is not well supported so far. You can read more.
select,
option {
-webkit-appearance: none;
}
button.resetDropdownButton::after {
content: "\2716";
}
.filterWrapper {
/* flex: 1;*/
margin: 0 1rem 1rem;
position: relative;
}
.filterWrapper label {
display: block;
margin-bottom: .25rem;
}
.filterItem {
position: relative;
}
.filterItem::after {
/*add arrow down from fa-icon*/
content: '\f107';
font: normal normal normal 12px/1 FontAwesome;
color: black;
right: 8px;
top: -2px;
height: 26px;
padding: 15px 0px 0px 8px;
position: absolute;
pointer-events: none;
}
.filterItem select {
width: 100%;
/*padding: 0.5rem 1rem;*/
padding-right: 2rem;
padding-left: 1rem;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
font-size: 1rem;
border-radius: 6px;
border: 2px solid #CBD2E0;
transition: .2s all;
cursor: pointer;
}
.filterItem select::-webkit-input-placeholder {
color: var(--grey);
}
.filterItem select:focus {
outline: none;
background-color: rgba(214, 238, 247, 0.5);
border: 1px solid var(--blue);
box-shadow: 0 0 3px var(--blue);
}
.filterItem select>option {
border-radius: 10px;
}
.filterWrapper .resetDropdownButton {
position: absolute;
top: auto;
right: 1.15rem;
bottom: .5rem;
background-color: transparent;
font-family: 'Roboto', sans-serif;
font-size: 1rem;
/* font-weight: bold;*/
border: 0 solid transparent;
cursor: pointer;
}
.filterWrapper .resetDropdownButton:hover {
text-decoration: underline;
}
select:disabled+button.resetDropdownButton::after {
color: gray;
opacity: 0.7;
}
select:disabled+button.resetDropdownButton:hover {
text-decoration: none;
}
.filterItem:has(select:disabled)::after {
/*add arrow down from fa-icon*/
color: gray;
opacity: 0.7;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" rel="stylesheet" />
<div class="filterWrapper">
<div class="filterItem">
<select disabled>
<option>A</option>
<option>B</option>
<option>C</option>
</select>
<button class="resetDropdownButton"></button>
</div>
</div>
Change HTML structure
You can change the HTML structure and include the arrow inside your .filterItem and after the select, while also applying some CSS to make it look good.
This is better and more supported so far.
Something like this:
select,
option {
-webkit-appearance: none;
}
button.resetDropdownButton::after {
content: "\2716";
}
.filterWrapper {
/* flex: 1;*/
margin: 0 1rem 1rem;
position: relative;
}
.filterWrapper label {
display: block;
margin-bottom: .25rem;
}
.filterItem {
position: relative;
}
.filterItem select {
width: 100%;
/*padding: 0.5rem 1rem;*/
padding-right: 2rem;
padding-left: 1rem;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
font-size: 1rem;
border-radius: 6px;
border: 2px solid #CBD2E0;
transition: .2s all;
cursor: pointer;
}
.filterItem select::-webkit-input-placeholder {
color: var(--grey);
}
.filterItem select:focus {
outline: none;
background-color: rgba(214, 238, 247, 0.5);
border: 1px solid var(--blue);
box-shadow: 0 0 3px var(--blue);
}
.filterItem select>option {
border-radius: 10px;
}
.filterWrapper .resetDropdownButton {
position: absolute;
top: auto;
right: 1.15rem;
bottom: .5rem;
background-color: transparent;
font-family: 'Roboto', sans-serif;
font-size: 1rem;
/* font-weight: bold;*/
border: 0 solid transparent;
cursor: pointer;
}
.filterWrapper .resetDropdownButton:hover {
text-decoration: underline;
}
select:disabled+button.resetDropdownButton::after {
color: gray;
opacity: 0.7;
}
select:disabled+button.resetDropdownButton:hover {
text-decoration: none;
}
.arrow::after {
/*add arrow down from fa-icon*/
content: '\f107';
font: normal normal normal 12px/1 FontAwesome;
color: black;
right: 8px;
top: -2px;
height: 26px;
padding: 15px 0px 0px 8px;
position: absolute;
pointer-events: none;
}
select:disabled + button.resetDropdownButton + span.arrow::after {
color: gray;
opacity: 0.7;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" rel="stylesheet" />
<div class="filterWrapper">
<div class="filterItem">
<select disabled>
<option>A</option>
<option>B</option>
<option>C</option>
</select>
<button class="resetDropdownButton"></button>
<span class="arrow"></span>
</div>
</div>
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>
I have the following code (below) of my form section and in it i want this (below image) underline animation to be done in the text input field . Whenever the user focus on the field the animation to be done.
the animation is to be smooth ease.
But something is missing i can't find in it. What is wrong and How to fix it?
Anyone Please help
html {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
text-rendering: optimizelegibility;
}
html, body {
height: 100%;
}
#contact {
font-family: "Montserrat", sans-serif;
font-size: 14px;
font-weight: 300;
letter-spacing: 3px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
margin: 10% 0;
}
#contact main, body footer {
width: 100%;
}
#contact main {
height: 100%;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.form .text-input, .form .textarea, .form .label, .form .button {
padding: 1em 1.5em;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
outline: none;
line-height: normal;
border: 1px solid transparent;
border-radius: 0;
}
.form .text-input, .form .textarea {
font: inherit;
line-height: normal;
width: 100%;
box-sizing: border-box;
display: block;
padding-left: 0;
border-bottom-color: #00d2ff;
background: transparent;
outline: none;
color: black;
}
.form .text-input:placeholder, .form .textarea:placeholder {
color: rgba(0, 0, 0, 0.7);
}
.form .text-input:-webkit-autofill, .form .textarea:-webkit-autofill {
box-shadow: 0 0 0px 1000px white inset;
border-top-color: white;
border-left-color: white;
border-right-color: white;
}
.form .error.text-input, .form .error.textarea, .error .form .text-input, .form .error .text-input, .error .form .textarea, .form .error .textarea {
border-color: transparent transparent red transparent;
}
.form:not(.has-floated-label) .text-input:active, .form:not(.has-floated-label) .textarea:active, .form:not(.has-floated-label) .text-input:focus, .form:not(.has-floated-label) .textarea:focus {
border-color: transparent transparent black transparent;
}
.form .label {
position: absolute;
z-index: 10;
pointer-events: none;
padding-left: 0;
}
.form .label {
top: 0;
left: 0;
color: rgba(0, 0, 0, 0.3);
-webkit-transition: color 0.3s;
transition: color 0.3s;
}
.active .form .label, .form .active .label {
font-size: 0.80em;
line-height: 1;
font-weight: 600;
text-transform: uppercase;
padding: 0;
color: rgba(0, 0, 0, 0.7);
background: white;
}
.focus .form .label, .form .focus .label {
color: black;
}
.form.has-floated-label .field:after {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 0%;
border-bottom: 3px solid #00d2ff;
-webkit-transition: width 0.3s cubic-bezier(0.455, 0.03, 0.515, 0.955);
transition: width 0.3s cubic-bezier(0.455, 0.03, 0.515, 0.955);
}
.form.has-floated-label .field.focus:after {
width: 100%;
}
.form .button {
font: inherit;
line-height: normal;
cursor: pointer;
background-color: #00d2ff;
color: white;
text-transform: uppercase;
text-align: center;
letter-spacing: 0.14286em;
transition-duration: 0.4s;
}
.form .button:hover, .form .button:focus, .form .button:active {
box-shadow: 0 10px 15px rgba(0, 0, 0, .1);
}
.form .button:active {
position: relative;
top: 1px;
left: 1px;
}
.form {
/* max-width: 50em; */
width: 100%;
margin: 0 10%;
/* padding: 1em 2em; */
box-sizing: border-box;
overflow: hidden;
}
.form .field {
position: relative;
width: 100%;
margin-bottom: 1.5em;
float: left;
}
#media screen and (min-width: 40em) {
.form .field.half {
width: calc(50% - 2em);
margin-right: 2em;
}
.form .field.half + .half {
margin-left: 2em;
margin-right: 0;
}
}
.form .field:last-child {
float: right;
width: auto;
}
.form .textarea {
max-width: 100%;
}
<section id="contact">
<main>
<form action='' class='form'>
<p class='field required half'>
<label class='label required' for='name'>Name</label>
<input class='text-input' id='name' name='name' required type='text'>
</p>
<p class='field required half'>
<label class='label' for='email'>E-mail</label>
<input class='text-input' id='email' name='email' required type='email'>
</p>
<p class='field'>
<label class='label' for='message'>Message</label>
<textarea class='textarea' cols='50' id='message' name='message' required rows='4'></textarea>
</p>
<p class='field'>
<input class='button' type='submit' value='Send message'>
</p>
</form>
</main>
</section>
This is an example:
.input-name{
position: relative;
display: inline-block;
overflow: hidden;
}
.input-name > input[type=text]{
border: none;
border-bottom: 2px solid red;
outline: none;
}
.underline-animation{
transition: all 0.5s;
display: inline-block;
bottom: 0;
left: -100%;
position: absolute;
width: 100%;
height: 2px;
background-color: #64e4fe;
}
.input-name > input[type=text]:focus + .underline-animation{
left: 0;
}
<div class="input-name">
<input type="text" placeholder="name">
<span class="underline-animation"></span>
</div>
I don't think this is possible with only the underline element since I know of no way to animate it like that, you can use the <hr> element though.
then you can do
hr{
position:relative;
left:0;
width:0%;
height:2px;
background-color:#1784E1;
border:none;
margin-top:0;
margin-left:0;
margin-bottom:20px;
transition:0.5s;
}
input:focus + hr{
width:100%;
}
if you go to sam.apostel.be/TAD, is that what you want?
This question already has answers here:
Flex / Grid layouts not working on button or fieldset elements
(3 answers)
Closed 5 years ago.
I've created a text field with a little cogwheel, that offers options in a popup menu about how to treat the search string. For some parts, it uses a flexible box layout.
In Firefox, I get the expected result:
.
In Webkit browsers (Safari and Vivaldi), I get this result:
As you can see, the cogwheel doesn't stay in line. This is my main concern. I'm not too worried about the menu text not stretching as that can easily be solved with giving any of its containers a width.
I currently don't have Chrome, but I suspect it might render it in a similar fashion as the other Webkit browsers.
Here is the css that I think is relevant to my problem.
.flex-search {
position: relative;
display: -webkit-flex; // <--
display: flex; // <--
-webkit-align-items: stretch; // <--
align-items: stretch; // <--
width: 100%;
border: 1px solid #222;
border-radius: .4em;
background-color: #fff;
}
.flex-search > :first-child {
-webkit-flex: 1; // <--
flex: 1; // <--
}
.flex-search > :last-child {
width: 2em; // <--
border-left: 1px solid #ccc;
cursor: pointer;
}
And here's a full code snippet of the search field:
$( '.flex-search input[type="radio"]' ).click( function() {
$( this ).closest( 'span' )
.css( 'display', 'none' )
.delay( 500 )
.queue( function ( next ) {
$( this ).removeAttr( 'style' );
next();
} );
$( this ).closest( 'fieldset' )
.find( 'input[type="text"]' )
.attr( 'placeholder', $( this ).closest( 'label' ).text() )
.focus();
} );
* {
margin: 0;
padding: 0;
border: medium none;
border-spacing: 0;
outline: none;
outline: 0;
color: inherit;
font-family: inherit;
font-size: inherit;
font-weight: inherit;
line-height: inherit;
text-align: inherit;
text-decoration: none;
text-indent: 0;
list-style: none outside none;
background: none repeat scroll 0 0 transparent;
}
*::-moz-focus-inner {
border: 0;
padding: 0;
}
html {
color: #222;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: normal;
text-align: left;
height: 100%;
}
body {
font-size: 1.4rem;
line-height: 1.5em;
min-height: 100%;
background-color: #fff;
}
div {
margin: 150px auto 0;
width: 300px;
}
::-webkit-input-placeholder {
color: #666;
font-size: 85%;
}
:-moz-placeholder {
color: #666;
font-size: 85%;
}
::-moz-placeholder {
color: #666;
font-size: 85%;
}
:-ms-input-placeholder {
color: #666;
font-size: 85%;
}
:focus::-webkit-input-placeholder {
color: #ccc;
}
:focus:-moz-placeholder {
color: #ccc;
}
:focus::-moz-placeholder {
color: #ccc;
}
:focus:-ms-input-placeholder {
color: #ccc;
}
.flex-search {
position: relative;
display: -webkit-flex;
display: flex;
-webkit-align-items: stretch;
align-items: stretch;
width: 100%;
border: 1px solid #222;
border-radius: .4em;
background-color: #fff;
}
.flex-search > :first-child {
-webkit-flex: 1;
flex: 1;
}
.flex-search > :last-child {
width: 2em;
border-left: 1px solid #ccc;
cursor: pointer;
}
.flex-search > :last-child:after {
content: '\00a0';
display: block;
width: 100%;
height: 100%;
background: url( 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAEG0lEQVQ4EQEQBO/7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhwAAAOwAAAASAAAAEgAAAOwAAACIAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAA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ABJRU5ErkJggg==' ) no-repeat center center;
opacity: 0.5;
}
.flex-search > :last-child:hover:after {
opacity: 1;
}
.flex-search > :last-child > :first-child {
position: absolute;
right: -1px;
bottom: 0;
display: none;
padding: 0 .25em 2.1em 0;
color: #fff;
}
.flex-search > :last-child:hover > :first-child {
display: block;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.flex-search label {
display: block;
cursor: pointer;
background-color: #ccc;
}
.flex-search label > span {
position: relative;
display: block;
font-size: 85%;
text-align: right;
padding: .2em .8em .2em 30%;
}
.flex-search label:hover > span,
.flex-search input[type="radio"]:checked ~ span {
color: #999;
background-color: #eee;
}
.flex-search input[type="radio"]:checked ~ span:before {
position: absolute;
left: .7em;
content: '✔';
}
.flex-search input[type="radio"] {
display: none;
}
.flex-search input[type="text"] {
width: 100%;
box-sizing: border-box;
padding: .2em .8em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<fieldset class="flex-search">
<span>
<input type="text" name="id" placeholder="contains">
</span>
<span>
<span>
<label><input type="radio" name="t-id" value="c" checked="checked"><span>contains</span></label>
<label><input type="radio" name="t-id" value="s"><span>starts with</span></label>
<label><input type="radio" name="t-id" value="e"><span>ends with</span></label>
<label><input type="radio" name="t-id" value="i"><span>equals</span></label>
</span>
</span>
</fieldset>
</div>
Do you have any idea why I am not getting the expected result in Webkit browsers and how I can get it to work in them?
I suspect my code might actually be more complex than it needs to be. If you have suggestions on how to simplify, that is greatly appreciated as well of course, but I'm mainly focused on how to make the current code work in Webkit browsers.
Why the cogwheel ends up on the second line is because of a webkit bug that does not render fieldset elements as a flexbox container
Here is a list of flexbugs mentioning the same bug: Some html elements cant be flex containers
If you add a div as an inner wrapper it will work.
<fieldset>
<div class="flex-search">
....
</div>
</fieldset>
Stack snippet
$('.flex-search input[type="radio"]').click(function() {
$(this).closest('span')
.css('display', 'none')
.delay(500)
.queue(function(next) {
$(this).removeAttr('style');
next();
});
$(this).closest('fieldset')
.find('input[type="text"]')
.attr('placeholder', $(this).closest('label').text())
.focus();
});
* {
margin: 0;
padding: 0;
border: medium none;
border-spacing: 0;
outline: none;
outline: 0;
color: inherit;
font-family: inherit;
font-size: inherit;
font-weight: inherit;
line-height: inherit;
text-align: inherit;
text-decoration: none;
text-indent: 0;
list-style: none outside none;
background: none repeat scroll 0 0 transparent;
}
*::-moz-focus-inner {
border: 0;
padding: 0;
}
html {
color: #222;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: normal;
text-align: left;
height: 100%;
}
body {
font-size: 1.4rem;
line-height: 1.5em;
min-height: 100%;
background-color: #fff;
}
div {
margin: 150px auto 0;
width: 300px;
}
::-webkit-input-placeholder {
color: #666;
font-size: 85%;
}
:-moz-placeholder {
color: #666;
font-size: 85%;
}
::-moz-placeholder {
color: #666;
font-size: 85%;
}
:-ms-input-placeholder {
color: #666;
font-size: 85%;
}
:focus::-webkit-input-placeholder {
color: #ccc;
}
:focus:-moz-placeholder {
color: #ccc;
}
:focus::-moz-placeholder {
color: #ccc;
}
:focus:-ms-input-placeholder {
color: #ccc;
}
.flex-search {
position: relative;
display: -webkit-flex;
display: flex;
-webkit-align-items: stretch;
align-items: stretch;
width: 100%;
border: 1px solid #222;
border-radius: .4em;
background-color: #fff;
}
.flex-search> :first-child {
-webkit-flex: 1;
flex: 1;
}
.flex-search> :last-child {
width: 2em;
border-left: 1px solid #ccc;
cursor: pointer;
}
.flex-search> :last-child:after {
content: '\00a0';
display: block;
width: 100%;
height: 100%;
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAEG0lEQVQ4EQEQBO/7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA6eSOOoDWnnAAAAABJRU5ErkJggg==') no-repeat center center;
opacity: 0.5;
}
.flex-search> :last-child:hover:after {
opacity: 1;
}
.flex-search> :last-child> :first-child {
position: absolute;
right: -1px;
bottom: 0;
display: none;
padding: 0 .25em 2.1em 0;
color: #fff;
}
.flex-search> :last-child:hover> :first-child {
display: block;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.flex-search label {
display: block;
cursor: pointer;
background-color: #ccc;
}
.flex-search label>span {
position: relative;
display: block;
font-size: 85%;
text-align: right;
padding: .2em .8em .2em 30%;
}
.flex-search label:hover>span,
.flex-search input[type="radio"]:checked~span {
color: #999;
background-color: #eee;
}
.flex-search input[type="radio"]:checked~span:before {
position: absolute;
left: .7em;
content: '✔';
}
.flex-search input[type="radio"] {
display: none;
}
.flex-search input[type="text"] {
width: 100%;
box-sizing: border-box;
padding: .2em .8em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<fieldset>
<div class="flex-search">
<span>
<input type="text" name="id" placeholder="contains">
</span>
<span>
<span>
<label><input type="radio" name="t-id" value="c" checked="checked"><span>contains</span></label>
<label><input type="radio" name="t-id" value="s"><span>starts with</span></label>
<label><input type="radio" name="t-id" value="e"><span>ends with</span></label>
<label><input type="radio" name="t-id" value="i"><span>equals</span></label>
</span>
</span>
</div>
</fieldset>
</div>
In the following, you say that the span should be padding-left: 30%. As a result the space for the text is too small. Just remove the 30% and it will work fine. You can also add .8em as a fourth parameter but the browser will do it automatically for you.
.flex-search label>span {
position: relative;
display: block;
font-size: 85%;
text-align: right;
padding: .2em .8em .2em; <-- 30% removed
}
$('.flex-search input[type="radio"]').click(function() {
$(this).closest('span')
.css('display', 'none')
.delay(500)
.queue(function(next) {
$(this).removeAttr('style');
next();
});
$(this).closest('fieldset')
.find('input[type="text"]')
.attr('placeholder', $(this).closest('label').text())
.focus();
});
* {
margin: 0;
padding: 0;
border: medium none;
border-spacing: 0;
outline: none;
outline: 0;
color: inherit;
font-family: inherit;
font-size: inherit;
font-weight: inherit;
line-height: inherit;
text-align: inherit;
text-decoration: none;
text-indent: 0;
list-style: none outside none;
background: none repeat scroll 0 0 transparent;
}
*::-moz-focus-inner {
border: 0;
padding: 0;
}
html {
color: #222;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: normal;
text-align: left;
height: 100%;
}
body {
font-size: 1.4rem;
line-height: 1.5em;
min-height: 100%;
background-color: #fff;
}
div {
margin: 150px auto 0;
width: 300px;
}
::-webkit-input-placeholder {
color: #666;
font-size: 85%;
}
:-moz-placeholder {
color: #666;
font-size: 85%;
}
::-moz-placeholder {
color: #666;
font-size: 85%;
}
:-ms-input-placeholder {
color: #666;
font-size: 85%;
}
:focus::-webkit-input-placeholder {
color: #ccc;
}
:focus:-moz-placeholder {
color: #ccc;
}
:focus::-moz-placeholder {
color: #ccc;
}
:focus:-ms-input-placeholder {
color: #ccc;
}
.flex-search {
position: relative;
display: -webkit-flex;
display: flex;
-webkit-align-items: stretch;
align-items: stretch;
width: 100%;
border: 1px solid #222;
border-radius: .4em;
background-color: #fff;
}
.flex-search> :first-child {
-webkit-flex: 1;
flex: 1;
}
.flex-search> :last-child {
width: 2em;
border-left: 1px solid #ccc;
cursor: pointer;
}
.flex-search> :last-child:after {
content: '\00a0';
display: block;
width: 100%;
height: 100%;
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAEG0lEQVQ4EQEQBO/7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA6eSOOoDWnnAAAAABJRU5ErkJggg==') no-repeat center center;
opacity: 0.5;
}
.flex-search> :last-child:hover:after {
opacity: 1;
}
.flex-search> :last-child> :first-child {
position: absolute;
right: -1px;
bottom: 0;
display: none;
padding: 0 .25em 2.1em 0;
color: #fff;
}
.flex-search> :last-child:hover> :first-child {
display: block;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.flex-search label {
display: block;
cursor: pointer;
background-color: #ccc;
}
.flex-search label>span {
position: relative;
display: block;
font-size: 85%;
text-align: right;
padding: .2em .8em .2em;
}
.flex-search label:hover>span,
.flex-search input[type="radio"]:checked~span {
color: #999;
background-color: #eee;
}
.flex-search input[type="radio"]:checked~span:before {
position: absolute;
left: .7em;
content: '✔';
}
.flex-search input[type="radio"] {
display: none;
}
.flex-search input[type="text"] {
width: 100%;
box-sizing: border-box;
padding: .2em .8em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<fieldset class="flex-search">
<span>
<input type="text" name="id" placeholder="contains">
</span>
<span>
<span>
<label><input type="radio" name="t-id" value="c" checked="checked"><span>contains</span></label>
<label><input type="radio" name="t-id" value="s"><span>starts with</span></label>
<label><input type="radio" name="t-id" value="e"><span>ends with</span></label>
<label><input type="radio" name="t-id" value="i"><span>equals</span></label>
</span>
</span>
</fieldset>
</div>
Update:
In the event that the 30% should give the check mark enough space, you can also replace it with 2em:
.flex-search label>span {
position: relative;
display: block;
font-size: 85%;
text-align: right;
padding: .2em .8em .2em 2em;
}
$('.flex-search input[type="radio"]').click(function() {
$(this).closest('span')
.css('display', 'none')
.delay(500)
.queue(function(next) {
$(this).removeAttr('style');
next();
});
$(this).closest('fieldset')
.find('input[type="text"]')
.attr('placeholder', $(this).closest('label').text())
.focus();
});
* {
margin: 0;
padding: 0;
border: medium none;
border-spacing: 0;
outline: none;
outline: 0;
color: inherit;
font-family: inherit;
font-size: inherit;
font-weight: inherit;
line-height: inherit;
text-align: inherit;
text-decoration: none;
text-indent: 0;
list-style: none outside none;
background: none repeat scroll 0 0 transparent;
}
*::-moz-focus-inner {
border: 0;
padding: 0;
}
html {
color: #222;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: normal;
text-align: left;
height: 100%;
}
body {
font-size: 1.4rem;
line-height: 1.5em;
min-height: 100%;
background-color: #fff;
}
div {
margin: 150px auto 0;
width: 300px;
}
::-webkit-input-placeholder {
color: #666;
font-size: 85%;
}
:-moz-placeholder {
color: #666;
font-size: 85%;
}
::-moz-placeholder {
color: #666;
font-size: 85%;
}
:-ms-input-placeholder {
color: #666;
font-size: 85%;
}
:focus::-webkit-input-placeholder {
color: #ccc;
}
:focus:-moz-placeholder {
color: #ccc;
}
:focus::-moz-placeholder {
color: #ccc;
}
:focus:-ms-input-placeholder {
color: #ccc;
}
.flex-search {
position: relative;
display: -webkit-flex;
display: flex;
-webkit-align-items: stretch;
align-items: stretch;
width: 100%;
border: 1px solid #222;
border-radius: .4em;
background-color: #fff;
}
.flex-search> :first-child {
-webkit-flex: 1;
flex: 1;
}
.flex-search> :last-child {
width: 2em;
border-left: 1px solid #ccc;
cursor: pointer;
}
.flex-search> :last-child:after {
content: '\00a0';
display: block;
width: 100%;
height: 100%;
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAEG0lEQVQ4EQEQBO/7AAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAhwAAAOwAAAASAAAAEgAAAOwAAACIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA6eSOOoDWnnAAAAABJRU5ErkJggg==') no-repeat center center;
opacity: 0.5;
}
.flex-search> :last-child:hover:after {
opacity: 1;
}
.flex-search> :last-child> :first-child {
position: absolute;
right: -1px;
bottom: 0;
display: none;
padding: 0 .25em 2.1em 0;
color: #fff;
}
.flex-search> :last-child:hover> :first-child {
display: block;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.flex-search label {
display: block;
cursor: pointer;
background-color: #ccc;
}
.flex-search label>span {
position: relative;
display: block;
font-size: 85%;
text-align: right;
padding: .2em .8em .2em 2em;
}
.flex-search label:hover>span,
.flex-search input[type="radio"]:checked~span {
color: #999;
background-color: #eee;
}
.flex-search input[type="radio"]:checked~span:before {
position: absolute;
left: .7em;
content: '✔';
}
.flex-search input[type="radio"] {
display: none;
}
.flex-search input[type="text"] {
width: 100%;
box-sizing: border-box;
padding: .2em .8em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<fieldset class="flex-search">
<span>
<input type="text" name="id" placeholder="contains">
</span>
<span>
<span>
<label><input type="radio" name="t-id" value="c" checked="checked"><span>contains</span></label>
<label><input type="radio" name="t-id" value="s"><span>starts with</span></label>
<label><input type="radio" name="t-id" value="e"><span>ends with</span></label>
<label><input type="radio" name="t-id" value="i"><span>equals</span></label>
</span>
</span>
</fieldset>
</div>
Connecting both solution from LGSon and this one, the result should be something like this:
$('.flex-search input[type="radio"]').click(function() {
$(this).closest('span')
.css('display', 'none')
.delay(500)
.queue(function(next) {
$(this).removeAttr('style');
next();
});
$(this).closest('fieldset')
.find('input[type="text"]')
.attr('placeholder', $(this).closest('label').text())
.focus();
});
* {
margin: 0;
padding: 0;
border: medium none;
border-spacing: 0;
outline: none;
outline: 0;
color: inherit;
font-family: inherit;
font-size: inherit;
font-weight: inherit;
line-height: inherit;
text-align: inherit;
text-decoration: none;
text-indent: 0;
list-style: none outside none;
background: none repeat scroll 0 0 transparent;
}
*::-moz-focus-inner {
border: 0;
padding: 0;
}
html {
color: #222;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: normal;
text-align: left;
height: 100%;
}
body {
font-size: 1.4rem;
line-height: 1.5em;
min-height: 100%;
background-color: #fff;
}
div {
margin: 150px auto 0;
width: 300px;
}
::-webkit-input-placeholder {
color: #666;
font-size: 85%;
}
:-moz-placeholder {
color: #666;
font-size: 85%;
}
::-moz-placeholder {
color: #666;
font-size: 85%;
}
:-ms-input-placeholder {
color: #666;
font-size: 85%;
}
:focus::-webkit-input-placeholder {
color: #ccc;
}
:focus:-moz-placeholder {
color: #ccc;
}
:focus::-moz-placeholder {
color: #ccc;
}
:focus:-ms-input-placeholder {
color: #ccc;
}
.flex-search {
position: relative;
display: -webkit-flex;
display: flex;
-webkit-align-items: stretch;
align-items: stretch;
width: 100%;
border: 1px solid #222;
border-radius: .4em;
background-color: #fff;
}
.flex-search> :first-child {
-webkit-flex: 1;
flex: 1;
}
.flex-search> :last-child {
width: 2em;
border-left: 1px solid #ccc;
cursor: pointer;
}
.flex-search> :last-child:after {
content: '\00a0';
display: block;
width: 100%;
height: 100%;
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAEG0lEQVQ4EQEQBO/7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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ASAAAAEgAAAOwAAACIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA6eSOOoDWnnAAAAABJRU5ErkJggg==') no-repeat center center;
opacity: 0.5;
}
.flex-search> :last-child:hover:after {
opacity: 1;
}
.flex-search> :last-child> :first-child {
position: absolute;
right: -1px;
bottom: 0;
display: none;
padding: 0 .25em 2.1em 0;
color: #fff;
}
.flex-search> :last-child:hover> :first-child {
display: block;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.flex-search label {
display: block;
cursor: pointer;
background-color: #ccc;
}
.flex-search label>span {
position: relative;
display: block;
font-size: 85%;
text-align: right;
padding: .2em .8em .2em 2em;
}
.flex-search label:hover>span,
.flex-search input[type="radio"]:checked~span {
color: #999;
background-color: #eee;
}
.flex-search input[type="radio"]:checked~span:before {
position: absolute;
left: .7em;
content: '✔';
}
.flex-search input[type="radio"] {
display: none;
}
.flex-search input[type="text"] {
width: 100%;
box-sizing: border-box;
padding: .2em .8em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<div class="flex-search">
<span>
<input type="text" name="id" placeholder="contains">
</span>
<span>
<span>
<label><input type="radio" name="t-id" value="c" checked="checked"><span>contains</span></label>
<label><input type="radio" name="t-id" value="s"><span>starts with</span></label>
<label><input type="radio" name="t-id" value="e"><span>ends with</span></label>
<label><input type="radio" name="t-id" value="i"><span>equals</span></label>
</span>
</span>
</div>
</div>
i'm trying to personalize the appearance of Checkbox but this only works in Google Chrome for mozilla doesn't work i dont know how to fix this here is my code:
Example:
Checkbox on jsfiddle.net
¡Please! before you post any response see example in the 2 browsers in
this case Chrome and Mozilla.
images from google chrome and mozilla
Chrome:
Mozilla
CSS:
#div-tallas .seleccion-talla .btn-default{
padding: 6px 7px;
font-weight: 600;
font-size: 1.2em;
letter-spacing: 0px;
min-width: 40px;
margin-left: 1px !important;
}
#div-tallas input[type="checkbox"] {
/* 1 */
display: inline-block;
height: 36px;
width: 36px;
border: 2px solid #000;
-moz-border: 2px solid #000;
/* 2 */
overflow: hidden;
/* 3 */
margin-top: -4px;
vertical-align: middle;
/* 4 */
-webkit-appearance: none;
-moz-appearance: none;
outline: 0;
/* 5 */
background: #e5e4e4;
-moz-background: #e5e4e4;
}
/*
* Checked
*/
#div-tallas input[type=checkbox]:checked {
/* 1 */
display: inline-block;
height: 36px;
width: 36px;
border: 2px solid #e5e4e4 !important;
-moz-border: 2px solid #e5e4e4 !important;
/* 2 */
overflow: hidden;
/* 3 */
margin-top: -4px;
vertical-align: middle;
/* 4 */
-webkit-appearance: none;
-moz-appearance: none;
outline: 0;
/* 5 */
background: #ff6500 !important;
background-color: #ff6500 !important;
padding: 2px;
transition: background 0.4s linear 0s, color 0.4s linear 0s;
}
/* Checkbox */
#div-tallas input[type=checkbox]:checked:before,
#div-tallas input[type=checkbox]:indeterminate:before {
content: "\f00c";
font-family: FontAwesome;
font-size: 32px;
-webkit-font-smoothing: antialiased;
text-align: center;
line-height: 26px;
color: #e5e4e4;
z-index: 888;
margin-left: -1px;
}
#div-tallas input[type=checkbox]:indeterminate:before {
content: "\f068";
}
How about styling the label?
#div-tallas {
background-color: #e5e4e4 !important;
min-height: 40vh;
}
#div-tallas input[type="checkbox"] {
display: none;
}
#div-tallas input[type="checkbox"] + label {
padding-left: 0;
}
#div-tallas input[type="checkbox"] + label:before {
/* 1 */
font: 32px/32px 'FontAwesome';
text-align: center;
display: inline-block;
height: 36px;
width: 36px;
border: 2px solid #000;
overflow: hidden;
margin-top: -4px;
vertical-align: middle;
background: transparent;
/* to show content */
content: "\00a0";
margin-right: 8px;
}
/*
* Checked
*/
#div-tallas input[type=checkbox]:checked + label:before {
border: 2px solid transparent;
background: #ff6500;
transition: background 0.4s linear 0s, color 0.4s linear 0s;
}
/* Checkbox */
#div-tallas input[type=checkbox]:checked + label:before,
#div-tallas input[type=checkbox]:indeterminate + label:before {
content: "\f00c";
color: #e5e4e4;
}
#div-tallas input[type=checkbox]:indeterminate + label:before {
content: "\f068";
}
jsfiddle
This isn't 100% perfect but it does show you a working example of a pure CSS checkbox that works in both Chrome and Firefox.
JSFiddle
HTML
<div id="div-tallas">
<div class="quiero-este">
<h5>¡Quiero este!</h5>
<div class="checkbox check-primary m-top-40 text-center">
<input type="checkbox" value="1" id="checkbox1" />
<label for="checkbox1"></label>
</div>
</div>
</div>
CSS
#div-tallas {
background-color: #e5e4e4 !important;
min-height: 40vh;
}
#div-tallas input[type=checkbox] {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background: transparent;
visibility: hidden;
}
#div-tallas input[type=checkbox],
#div-tallas input[type=checkbox] + label::before {
cursor: pointer;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
#div-tallas input[type=checkbox] + label::before {
content: '';
text-align: center;
background: #e5e4e4;
display: inline-block;
pointer-events: none;
opacity: 1;
color: black;
border: 3px solid black;
width: 36px;
height: 36px;
}
#div-tallas input[type=checkbox] + label {
line-height: 20px;
margin: 0 15px 0 15px;
}
#div-tallas input[type=checkbox]:hover {
cursor: pointer;
}
#div-tallas input[type=checkbox]:hover + label::before {
content: '';
background: #e5e4e4;
}
#div-tallas input[type=checkbox]:checked + label::before {
background: #ff6500 !important;
background-color: #ff6500 !important;
outline: 0;
content: "\f00c";
font-family: FontAwesome;
font-size: 32px;
-webkit-font-smoothing: antialiased;
text-align: center;
line-height: 26px;
color: #e5e4e4;
z-index: 888;
margin-left: -1px;
}
#div-tallas input[type=checkbox]:checked:hover + label::before {
opacity: 1;
}
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
}
Hope this helps.