I'm trying to create a button with Zurb Foundation using Rails for uploading a picture. I tried this:
<input class="tiny round disabled button" name="picture[picture]" type="file">
Unfortunately, it didn't work and created two different buttons that let you choose a picture. Is there anything I need to do specifically for file fields?
I've found this resource to be very helpful with styling input type="file" :
http://www.quirksmode.org/dom/inputfile.html
It's notoriously difficult but this essentially involves layering the actual input with a fake one that has your styling applied to it.
<div class="file-inputs">
<input type="file" class="hidden-input">
<div class="fake-input">
<input>
<img src="images/YOURBUTTON.png">
</div>
</div>
To go with the following CSS:
div.file-inputs {
position: relative;
}
div.hidden-input {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
}
input.file {
position: relative;
text-align: right;
-moz-opacity:0 ;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 2;
}
Custom file upload button using html css and js
Html code:
<div class="custom-file-upload">
<!--<label for="file">File: </label>-->
<input type="file" id="file" name="myfiles[]" multiple />
</div>
CSS:
.custom-file-upload-hidden {
display: none;
visibility: hidden;
position: absolute;
left: -9999px;
}
.custom-file-upload {
display: block;
width: auto;
font-size: 16px;
margin-top: 30px;
}
.custom-file-upload label {
display: block;
margin-bottom: 5px;
}
.file-upload-wrapper {
position: relative;
margin-bottom: 5px;
}
.file-upload-input {
width: 300px;
color: #fff;
font-size: 16px;
padding: 11px 17px;
border: none;
background-color: #c0392b;
-moz-transition: all 0.2s ease-in;
-o-transition: all 0.2s ease-in;
-webkit-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
float: left;
/* IE 9 Fix */
}
.file-upload-input:hover, .file-upload-input:focus {
background-color: #ab3326;
outline: none;
}
.file-upload-button {
cursor: pointer;
display: inline-block;
color: #fff;
font-size: 16px;
text-transform: uppercase;
padding: 11px 20px;
border: none;
margin-left: -1px;
background-color: #962d22;
float: left;
/* IE 9 Fix */
-moz-transition: all 0.2s ease-in;
-o-transition: all 0.2s ease-in;
-webkit-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
}
.file-upload-button:hover {
background-color: #6d2018;
}
JS CODE:
http://codepen.io/wallaceerick/pen/fEdrz check this one for complete details
The trick is to do something that looks like this:
HTML
<button class="file-upload">Upload
<input type="file" name="files" />
</button>
CSS
button.file-upload > input[type='file'] {
cursor: pointer;
position: absolute;
font-size: 0;
top: 0;
left: 0;
opacity: 0;
height: 100%;
width: 100%;
}
Using foundation v5.5.2: http://codepen.io/soyuka/pen/xGMPKJ
Related
I'm using Word Press with Mikado theme and have created a widget for a button the code for the button is in html. However, when I go to additional css under appearance and enter my css the link stops working. The html works (link wise) until I use the css. Any thoughts?
.wp-block-button {
position: relative;
height: 20px;
line-height: 20px;
text-align: center;
transition: 0s;
padding: 20px 20px;
cursor: pointer;
transition: 0s;
}
.wp-block-button {
background-color: transparent!important;
border-color: transparent!important;
color: #000000!important;
}
.wp-block-button:hover:before {
transition-delay: 0s;
}
.wp-block-button:before {
width: 0%;
height: 100%;
z-index: 3;
content: '';
position: absolute;
bottom: .1em;
left: 2em;
box-sizing: border-box;
transition: 0s;
}
.wp-block-button:hover:before {
width: 80% !important;
transition: 0s;
}
.wp-block-button:before {
border-bottom: 3px solid #59629a!important;
}
<div class="wp-block-button has-custom-width wp-block-button__width-100 has-custom-font-size is-style-outline" style="font-size:18px">
<a class="wp-block-button__link has-white-color has-text-color has-background wp-element-button" href="https://rothgrouplaw.com/new-client-intake-form/" style="border-radius:0px;background-color:#111e6e">Schedule Your Free Evaluation
</a>
</div>
Try taking out the position: relative; from the .wp-block-button class. I think that is your problem.
I am encountering a problem with a radio button in IE 11.
I have a simple radio button that makes my content scroll down once checked.
Without any styles applied, there is no problem. But with, the problem is back.
Does it have something to do with the IE render engine?
.switch {
position: relative;
display: block;
width: 34px;
height: 18px;
border-radius: 8px;
cursor: pointer;
outline: 0;
height: 18px;
top: 5px;
background-color: $grey-light;
box-shadow: $switch-shadow;
&::before {
content: " ";
position: absolute;
left: 2px;
top: 2px;
border-radius: 50%;
margin: 0;
outline: none;
height: 14px;
width: 14px;
background: white;
transition: background-color .08s ease-in;
}
&.active::before {
background-color: $green-dark;
left: 18px;
transition: background-color .08s ease-in, left .08s ease-in;
}
&.inactive::before {
background-color: $grey-dark;
left: 2px;
transition: background-color .08s ease-in, left .08s ease-in;
}
input[type=checkbox] {
// display: none;
visibility: hidden;
position: absolute;
z-index: -1;
}
}
Thanks for your help!
EDIT.
I forgot to precise that the scrolling box (flex: 1) has a parent which has display: flex.
I've a form in which I've a file upload filed I did customized it to fit the color theme which the PHP form is using it works but it's just static. I wanted to add a small transition to the button which I archived following the W3Schools tutorial.
But after that I'm facing a problem which I really don't have an idea how to solve. I did a search on this matter but most answers suggest to use bootstrap which I also tried and it messed up my current projects CSS.
Can some one show me what I'm doing wrong with the animation part.
.fileUpload {
float: left;
position: relative;
overflow: hidden;
background-color: #4068E0;
color: white;
height: 30px;
width: 120px;
text-align: center;
border: 2px solid #4068E0;
border-radius: 20px;
box-shadow: 2px 2px 1px 1px rgba(0, 0, 0, 0.4);
-webkit-transition: prop 0.4s;
-moz-transition: prop 0.4s;
-ms-transition: prop 0.4s;
-o-transition: prop 0.4s;
transition: prop 0.4s;
}
.fileUpload:after {
content: "";
background: #85b7e8;
display: block;
position: absolute;
opacity: 0;
transition: all 0.8s;
padding-top: 300%;
padding-left: 350%;
margin-left: -20px!important;
margin-top: -120%;
font-size: 20px;
cursor: pointer;
filter: alpha(opacity=0);
height: 100%;
text-align: center;
}
.fileUpload:active:after {
padding: 0;
margin: 0;
opacity: 1;
transition: 0s
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 0;
padding: 0;
font-size: 20px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
height: 100%;
text-align: center;
}
.fileName {
margin: 2px 0 0 130px;
width: auto;
}
.updLabel {
line-height: 30px;
font-weight: bold;
}
#uploadFile {
border: none;
width: 150px;
height: 30px;
}
<div class="usrCreate-form-right">
<div class="fileUpload">
<span class="updLabel">Add Image</span>
<input type="file" id="uploadFile" class="upload">
</div>
<div class="fileName">
<input id="uploadFile" placeholder="0 files selected" disabled>
</div>
</div>
As you can see in the above snippet the animation does happens but it doesn't pop the file selection window. If I disable the animation part it does pop up I tried few other things which also didn't work that's why I decided to ask here.
I've got success with your code when I add a z-index on the input. I tried with z-index: 1 and it worked. the visuals on the button won't change.
.fileUpload > input {
z-index: 1;
}
I have a progress bar that uses arrows but the only way I know how to make it is using pixels. So I am wondering if there is a way to create this progress bar using pixels, and then change its size according to the page. I have looked at similar questions, but none pertain to the type of element I am creating. Attached is what the bar currently looks like, and I want to be able to make it adaptable to the screen size.
.containerr {
font-family: 'Lato', sans-serif;
float: left;
position: relative;
width: 70%;
height: 100%;
}
.wrapperr {
float: left;
width: 70%;
height: 100%;
position: relative;
/*overflow:auto;*/
}
.pull-right {
}
a:hover {
color: #999;
}
/* Breadcrups CSS */
.arrow-steps {
zoom: 1.4;
position: relative;
display: inline-flex;
vertical-align: top;
}
.arrow-steps .step {
font-size: 100%;
text-align: center;
color: #666;
cursor: default;
margin: 0 3px;
padding: 10px 10px 10px 30px;
min-width: 180px;
float: left;
position: relative;
background-color: #d9e3f7;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
transition: background-color 0.2s ease;
}
.arrow-steps .step:after, .arrow-steps .step:before {
content: " ";
position: absolute;
top: 0;
right: -17px;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 19px solid transparent;
border-left: 17px solid #d9e3f7;
z-index: 2;
transition: border-color 0.2s ease;
}
.arrow-steps .step:before {
right: auto;
left: 0;
border-left: 17px solid #333;
z-index: 0;
}
.arrow-steps .step:first-child:before {
border: none;
}
.arrow-steps .step:first-child {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.arrow-steps .step span {
position: relative;
}
.arrow-steps .step span:before {
opacity: 0;
content: "✔";
position: absolute;
top: -2px;
left: -20px;
}
.arrow-steps .step.done span:before {
opacity: 1;
-webkit-transition: opacity 0.3s ease 0.5s;
-moz-transition: opacity 0.3s ease 0.5s;
-ms-transition: opacity 0.3s ease 0.5s;
transition: opacity 0.3s ease 0.5s;
}
.arrow-steps .step.current {
color: #fff;
background-color: #23468c;[![enter image description here][1]][1]
}
html
<div class="containerr">
<div class="wrapperr">
<div class="arrow-steps clearfix">
<div runat="server" id="first" class="step">
<asp:LinkButton ID="machineLink" CssClass="arrowTexts" runat="server" OnClick="machineLink_Click" OnClientClick="getCoordinates()">Safety</asp:LinkButton>
</div>
<div runat="server" id="second" class="step">
<asp:LinkButton ID="estopLink" CssClass="arrowTexts" runat="server" OnClick="estop_Click" OnClientClick="getCoordinates()">Estop Reset
</asp:LinkButton>
</div>
<div runat="server" id="third" class="step">
<asp:LinkButton ID="startLink" CssClass="arrowTexts" runat="server" OnClick="start_Click" OnClientClick="getCoordinates()">Start</asp:LinkButton>
</div>
</div>
</div>
</div>
You can utilize vh vw vmin and vmax to make your progress-bar responsive.
See this codepen
I have a switch button. But it doesn't work with the input type radio. If I try with checkbox button it works. Why? How can I solve, maintaining the radio input?
#charset "utf-8";
/* CSS Document */
/* ---------- GENERAL ---------- */
body {
background: #4a4a4a;
color: #151515;
font: 100%/1.5em "Lato", sans-serif;
margin: 0;
}
input {
font-family: inherit;
font-size: 100%;
line-height: normal;
margin: 0;
}
input[type="radio"] {
box-sizing: border-box;
padding: 0;
}
/* ---------- SWITCH ---------- */
.container {
height: 64px;
left: 50%;
margin: -32px 0 0 -80px;
position: absolute;
top: 50%;
width: 160px;
}
.switch {
background: #fff;
border-radius: 32px;
display: block;
height: 64px;
position: relative;
width: 160px;
}
.switch label {
color: #fff;
font-size: 48px;
font-weight: 300;
line-height: 64px;
text-transform: uppercase;
-webkit-transition: color .2s ease;
-moz-transition: color .2s ease;
-ms-transition: color .2s ease;
-o-transition: color .2s ease;
transition: color .2s ease;
width: 100px;
}
.switch label:nth-of-type(1) {
left: -75%;
position: absolute;
text-align: right;
}
.switch label:nth-of-type(2) {
position: absolute;
right: -75%;
text-align: left;
}
.switch input {
height: 64px;
left: 0;
opacity: 0;
position: absolute;
top: 0;
width: 160px;
z-index: 2;
}
.switch input:checked~label:nth-of-type(1) { color: #fff; }
.switch input:checked~label:nth-of-type(2) { color: #808080; }
.switch input~:checked~label:nth-of-type(1) { color: #808080; }
.switch input~:checked~label:nth-of-type(2) { color: #fff; }
.switch input:checked~.toggle {
left: 4px;
}
.switch input~:checked~.toggle {
left: 100px;
}
.switch input:checked {
z-index: 0;
}
.toggle {
background: #4a4a4a;
border-radius: 50%;
height: 56px;
left: 0;
position: absolute;
top: 4px;
-webkit-transition: left .2s ease;
-moz-transition: left .2s ease;
-ms-transition: left .2s ease;
-o-transition: left .2s ease;
transition: left .2s ease;
width: 56px;
z-index: 1;
}
.c-window{
display: block;
position: absolute;
width: 235px;
height: 235px;
margin: 0 auto;
border-radius: 100%;
border: 8px solid #FFB399;
background: #5ddfe8;
box-shadow: 0px 0px 5px rgba(0,0,0,0.25) inset;
overflow: hidden;
transition: background 1s ease-in-out;
}
input[type="radio"]:checked ~ .c-window {
background: #111;
}
<div class="container">
<div class="c-window"></div>
<div class="switch white">
<input type="radio" name="switch" id="switch-off">
<input type="radio" name="switch" id="switch-on" checked>
<label for="switch-off">On</label>
<label for="switch-on">Off</label>
<span class="toggle"></span>
</div> <!-- end switch -->
</div> <!-- end container -->
I'd like that the .c-window changes the background colour when it switch
you had a few typos, as mentioned by #fcalderan in comments.
you need to have .c-window as sibling, change the HTML markup and add z-index:-1 to it.
and you need to specify which input is going to change the background color.
/* CSS Document */
/* ---------- GENERAL ---------- */
body {
background: #4a4a4a;
color: #151515;
font: 100%/1.5em"Lato", sans-serif;
margin: 0;
}
input {
font-family: inherit;
font-size: 100%;
line-height: normal;
margin: 0;
}
input[type="radio"] {
box-sizing: border-box;
padding: 0;
}
/* ---------- SWITCH ---------- */
.container {
height: 64px;
left: 50%;
margin: -32px 0 0 -80px;
position: absolute;
top: 50%;
width: 160px;
}
.switch {
background: #fff;
border-radius: 32px;
display: block;
height: 64px;
position: relative;
width: 160px;
}
.switch label {
color: #fff;
font-size: 48px;
font-weight: 300;
line-height: 64px;
text-transform: uppercase;
-webkit-transition: color .2s ease;
-moz-transition: color .2s ease;
-ms-transition: color .2s ease;
-o-transition: color .2s ease;
transition: color .2s ease;
width: 100px;
}
.switch label:first-of-type {
left: -75%;
position: absolute;
text-align: right;
}
.switch label:last-of-type {
position: absolute;
right: -75%;
text-align: left;
}
.switch input {
height: 64px;
left: 0;
opacity: 0;
position: absolute;
top: 0;
width: 160px;
z-index: 2;
}
.switch input:checked~label:first-of-type {
color: #fff;
}
.switch input:checked~label:last-of-type {
color: #808080;
}
.switch input:checked~label:first-of-type {
color: #808080;
}
.switch input:checked~label:last-of-type {
color: #fff;
}
.switch input:checked {
z-index: 0;
}
.switch input:checked~.toggle {
left: 4px;
}
.switch input~:checked~.toggle {
left: 100px;
}
.toggle {
background: #4a4a4a;
border-radius: 50%;
height: 56px;
left: 0;
position: absolute;
top: 4px;
-webkit-transition: left .2s ease;
-moz-transition: left .2s ease;
-ms-transition: left .2s ease;
-o-transition: left .2s ease;
transition: left .2s ease;
width: 56px;
z-index: 1;
}
.c-window {
display: block;
position: absolute;
width: 235px;
height: 235px;
margin: 0 auto;
border-radius: 100%;
border: 8px solid #FFB399;
background: #5ddfe8;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.25) inset;
overflow: hidden;
transition: background 1s ease-in-out;
z-index:-1
}
input:last-of-type[type="radio"]:checked ~ .c-window {
background: #111;
}
<div class="container">
<div class="switch white">
<input type="radio" name="switch" id="switch-off">
<input type="radio" name="switch" id="switch-on" checked>
<label for="switch-off">On</label>
<label for="switch-on">Off</label>
<span class="toggle"></span>
<div class="c-window"></div>
</div>
<!-- end switch -->
</div>
<!-- end container -->
Can't you do it in javascript/jQuery?
HTML:
<div class="container">
<div class="c-window"></div>
<div class="switch white">
<input type="radio" name="switch" value="0" id="switch-off" class="switch">
<input type="radio" name="switch" value="1" id="switch-on" class="switch" checked>
<label for="switch-off">On</label>
<label for="switch-on">Off</label>
<span class="toggle"></span>
</div> <!-- end switch -->
</div> <!-- end container -->
jQuery (to catch the change event):
$(document).ready(function(){
$('.switch').on('change', function(ev){
if ($(this).val() == 0){
//do some stuff you want when off
}else{
//do some stuff you want when on
}
});
});
If you want to use ~ selector your code should go like this
body, html {
margin: 0;
padding: 0;
}
.content {
display: flex;
height: 100vh;
align-items: center;
justify-content: center;
position: relative;
}
.c-window {
position: absolute;
transition: all 0.3s ease-in;
width: 235px;
height: 235px;
border-radius: 50%;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background: #aaa;
border: 5px solid black;
z-index: 1;
}
input {
position: relative;
z-index: 2;
}
#switch-off:checked ~ .c-window {
background: blue;
}
#switch-on:checked ~ .c-window {
background: #aaa;
}
<div class="content">
<input type="radio" name="switch" id="switch-off">
<input type="radio" name="switch" id="switch-on" checked>
<div class="c-window"></div>
</div>