Adding style to file upload button in css - html

I have a text field and button with following css:
JS fiddle link : http://jsfiddle.net/Tdkre/
.submit {
-moz-box-shadow:inset 0px 1px 0px 0px #cae3fc;
-webkit-box-shadow:inset 0px 1px 0px 0px #cae3fc;
box-shadow:inset 0px 1px 0px 0px #cae3fc;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #79bbff), color-stop(1, #4197ee) );
background:-moz-linear-gradient( center top, #79bbff 5%, #4197ee 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#79bbff', endColorstr='#4197ee');
background-color:#79bbff;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #469df5;
display:inline-block;
color:#ffffff;
font-family:arial;
font-size:14px;
font-weight:bold;
padding:5px 14px;
text-decoration:none;
text-shadow:1px 1px 0px #287ace;
cursor:pointer;
}
.submit:hover {
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #4197ee), color-stop(1, #79bbff) );
background:-moz-linear-gradient( center top, #4197ee 5%, #79bbff 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#4197ee', endColorstr='#79bbff');
background-color:#4197ee;
}
.submit:active {
position:relative;
top:1px;
}
.text-input {
padding: 6px;
font-size: 13px;
border: 1px solid #d5d5d5;
color: #333;
border-radius: 4px 4px 4px 4px !important;
}
<form>
<input type="text" class="text-input" size="40"/>
<input type="button" value="Upload" id="upload" class="submit"/>
</form>
I want to add the same style to the file upload input type. I am a css beginner. How can i use this style to file upload button?

Try this solution: http://jsfiddle.net/JJRrc/1/
Html
<p class="form">
<input type="text" id="path" />
<label class="add-photo-btn">upload
<span>
<input type="file" id="myfile" name="myfile" />
</span>
</label>
</p>
CSS
.form input[type="file"]{
z-index: 999;
line-height: 0;
font-size: 50px;
position: absolute;
opacity: 0;
filter: alpha(opacity = 0);-ms-filter: "alpha(opacity=0)";
cursor: pointer;
_cursor: hand;
margin: 0;
padding:0;
left:0;
}
.add-photo-btn{
position:relative;
overflow:hidden;
cursor:pointer;
text-align:center;
background-color:#83b81a;
color:#fff;
display:block;
width:197px;
height:31px;
font-size:18px;
line-height:30px;
float:left;
}
input[type="text"]{
float:left;
}
JQuery
$('#myfile').change(function(){
$('#path').val($(this).val());
});

I tried this it looks pretty good to me. Are there any flaws with this?
Here is the jsfiddle link http://jsfiddle.net/Tdkre/1/
#FileUpload {
position:relative;
}
#BrowserVisible {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
background:url(upload.png) 100% 1px no-repeat;
width:345px;
height:30px;
}
#FileField {
width:250px;
margin-right:85px;
padding: 6px;
font-size: 13px;
background: #fff url('bg-form-field.gif') top left repeat-x;
border: 1px solid #d5d5d5;
color: #333;
border-radius: 4px 4px 4px 4px !important;
}
#BrowserHidden {
position:relative;
width:345px;
height:30px;
text-align: right;
-moz-opacity:0;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 2;
}
<div id="FileUpload">
<input type="file" size="24" id="BrowserHidden" onchange="getElementById('FileField').value = getElementById('BrowserHidden').value;" />
<div id="BrowserVisible"><input type="text" id="FileField" /></div>
Here are the images

You could also use jQuery, like this:
<img id="image" style="cursor:pointer;" src="img.jpg" />
<input type='file' style="display:none;" name="photosubmit" id="photosubmit"/>
And this jquery code
$("#image").click(function(){
$("#photosubmit").click();
});
Hopes this helps someone too!

try this:
In your css file put this on the end of file or somewhere else: input[type="file"]::-webkit-file-upload-button.
This syntax is only for button style.
If you put there only: input[type="file"] you can style the array where you have filename.

It is notoriously hard to style file upload buttons, but if you are willing to use jQuery and a plugin I've found this one to be very useful.
It gives you the posibility to "fake" file upload button functionality on any DOM element, so you can style it any way you want. Works well in all major browsers including old IE versions.

I run this relatively short jQuery on my page that contains one or more unaltered html <input type="file"> elements.
The jQuery will hide the elements and insert new ones where appropriate that mimic the same behaviour.
This answer is similar to others on the page but has been tested in IE browsers as well as the ones whose developer's actually take the time to support carefully considered web standards.
$(document).ready(function(){
// replace all file upload elements for styling purposes
$('input[type="file"]').each(function(){
var btn = $('<button class="file">Browse...</button>');
var txt = $('<span class="file"></span>');
$(this).after(txt).after(btn);
$(this).css({display:'none'});
var target = this;
$(btn).click(function(ev){
ev.preventDefault();
$(target).click();
})
$(target).change(function(){
// IE uses a stupid renaming scheme that includes "fake-path"
var fname = $(target).val()
$(txt).html(fname.substr(fname.lastIndexOf('\\')+1));
});
});
});
Now you just need to style button.file and span.file as you like and you are good to go.

Here is a link. You can change style of button.
HTML
<button>upload</button>
<input type="text" id="f" disabled="disabled" />
<input id="html_btn" type='file' " /><br>
CSS
button {
border-radius:10px;
padding:5px;
}
#html_btn {
display:none;
}
Javascript
$('button').bind("click", function () {
$('#html_btn').click();
});
$('#html_btn').change(function () {
document.getElementById("f").value = $('#html_btn').val();
});

Simple Solution: Custom file upload button with css only
.fileUpload input[type=file]{
display:none;
}
.btn{
background-color:#e3e3e3;
color:#333;
border:1px solid #e6e6e6;
border-radius:3px;
padding:6px 12px;
font-size:16px;
}
<label class="btn fileUpload btn-default">
Browse <input type="file" hidden="">
</label>

You can use pseudo attribute to apply css to upload button.
<input type="file"/>
input::-webkit-file-upload-button
{
background:blue;
color:white;
/* like this add your style */
}
Please enable show user agent shadow DOM to inspect shadow elements
Go to Browser >> DevTool (F12) >> settings >> Preferences >> Elements

Related

buttons cant be styled in css

Here are my buttons:
<body>
<form name="form1">
<span id="buttons">
<input type="button" name="button1" value="6"/>
<input type="button" name="button2" value="4"/>
<input type="button" name="button3" value="2"/>
</span>
</form>>
</body>
I cant for the life of me get them to be styled in css, I just dont know their identifier?
currently I'm using
<style>
#buttons {
"css style is here"
}
and that looks REALLY BAD
another method I tried was
<style>
input[type="button"] {
"css style is here"
}
which is exactly what I wanted, BUT absolute positioning made them all bunch up in the exact same space and I found no way to separate them.
I need either a way to clasify them and style them seperatly OR to space them when using the second method
"sidenote" Here's the css styling I used that caused them to bunch up:
<style>
input[type="button"] {
background:linear-gradient(to bottom, #44c767 5%, #05aaf7 100%);
display:inline-block;
border-radius:6px;
border:0px solid #83c41a;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:17px;
padding:16px 31px;
text-decoration:none;
text-shadow:0px 1px 0px #2f6627;
position:absolute;
left: 45%;
top: 30%;
}
</style>

Input "submit" inside textarea not clickable in Firefox

I have a simple form that allows users to send mails to the site's owner. I wouldn't like to change it totally, because I've got already written PHP script for this, and this solution worked fine before I tried to add some styles to it...
The problem is, "Wyślij >" (submit) inside the textarea does not work ONLY in firefox. I can't click it, like the button is somewhere underneath. In Opera, Chrome, Edge, IE - it works just fine. I'm starting to giving up on this. I would appreciate any help, I don't know what's causing this.
JSFiddle: http://jsfiddle.net/c0vz64m1/
HTML code:
<form method="post" action="kontakt.php" id="contactform" style="margin-left:35vw; margin-top:20px;">
<label for="name">Imię<font color="white">*</font>:</label><br>
<input type="text" name="name" id="name" placeholder=" Twoje imię (wymagane)" required /><br>
<label for="email">Email<font color="white">*</font>:</label><br>
<input type="text" name="email" id="email" placeholder=" Twój email (wymagane)" required />
<div id="text-area">
<label for="message">Wiadomość<font color="white">*</font>:</label><br>
<textarea name="message" rows="9" cols="50" id="message" placeholder=" Twoja wiadomość (wymagane)" equired></textarea>
<input type="submit" name="submit" value="Wyślij »" class="submit-button"/></div>
</form>
CSS:
input#name,input#email {
box-shadow:0px 0px 10px skyblue;
border:2px solid skyblue;
border-radius:7px;
padding-left:5px;
transition:all .2s ease-in-out;
}
input#name:focus,input#email:focus {
box-shadow:0px 0px 20px skyblue;
transition:all .2s ease-in-out;
}
input#name:hover,input#email:hover {
box-shadow:0px 0px 20px skyblue;
}
.submit-button {
width:75px;
height:36px;
margin-left:380px;
display:block;
margin-top:-41px;
border-top:2px solid blue;
z-index:5000;
font-size:14pt;
color:skyblue;
font-family:Andada;
}
textarea {
box-shadow:0px 0px 10px skyblue;
border:2px solid skyblue;
border-radius:10px;
resize:none;
height:150px;
width:375px;
z-index:1;
padding-right:75px;
transition:all .2s ease-in-out;
}
textarea:focus {
box-shadow:0px 0px 20px skyblue;
transition:all .2s ease-in-out;
}
textarea:hover {
box-shadow:0px 0px 20px skyblue;
}
Use absolute positioning to put the button over the textarea and it will work.
Remove from class .submit-button these things:
margin-left:380px;
margin-top:-41px;
and add these:
position:absolute;
right: 0;
bottom: 30px;
Then add position:relative to #text-area .
Please see updated fiddle: http://jsfiddle.net/w86o8hhh/ which adds:
z-index:10;
to the CSS, and:
id="submit"
to the submit button

Make Text Input Box Transparent? Should be simple?

I'm trying to make my form input transparent and over lay it on top of my div. Basically I want the text field to be transparent to whatever is behind it. Any suggestions?
<head>
<style type="text/css">
.WRAPPER {
background-color: #000;
height: 575px;
width: 975px;
background-image: url(exit-gate/exit-gate-bg.png);
top: auto;
margin: -8px;
}
body {
background-color: #000;
}
</style>
<style type="text/css">
term {
background: transparent;
border: none;
}
</style>
</head>
<body>
<div id="WRAPPER">
<div class="term"><input name="email" type="text" id="email">
<form name="form1" method="post" action="insert_ac.php">
<input type="image" src="exit-gate/white-box-10.png" alt="{alternate text}" name="submit" value="submit">
</form>
</div>
</div>
</body>
</html>
</div>
Try:
#email {
background-color:rgba(0, 0, 0, 0);
color:white;
border: none;
outline:none;
height:30px;
transition:height 1s;
-webkit-transition:height 1s;
}
#email:focus {
height:50px;
font-size:16px;
}
DEMO here.
this looks ways too simple but it worked for me:
<input type="text" id="SI"/>
this is my input field, I gave it an ID(SI), then in my CSS:
#SI{
background-color:transparent;
}
added the transparency to the element with SI id; the background became visible.
Also worth noting, on macOS and iOS, in any browser, the "user agent stylesheet" will override textbox style. You can override this (including the ::focus glow) by adding !important.
#mybox {
background-color: transparent!important;
border-color: transparent!important;
outline: transparent!important;
}
<input type="text" id="mybox" value="Textbox" />
saying I want a transparent color is like having the parent's color so put the value of background-color as inherit.
for me this helped:
<input type="text" />
style:
input {
background-color:inherit;
}
<style type="text/css">
input {
background-color : white;
border-color: transparent;
}
</style>
<input type="text" />

Change search form button text to image

I can't seem to get my head around the following problem. So I procured a template of a search form which I then changed to fit my design requirements but I can't seem to be able to change the value=s bit to an image of a search box button. Please see http://jsfiddle.net/p9URB/. The code is as follows:
HTML
<form action="/search" method="get" id="search_form" class="clearfix voicetron" data-ds-protection="enabled">
<div id="search_holder">
<input type="text" id="search_field" name="q" value="" title="Enter search term" placeholder="Search" data-validators="required" data-speech-enabled="" data-search-engine="oracle" x-webkit-speech="x-webkit-speech" autocomplete="off">
<input type="text" id="search_suggest" value="" placeholder="" disabled="">
<input type="submit" value="y" data-submit-text="s" class="btn_search iconify" title="Search">
</div>
</form>
CSS
#search_form{
position:relative;
margin:10px 0;
float:right
}
#search_form #search_holder{
display:block
}
#search_form #search_holder input[type="text"]{
font-size:13px;
width:180px;
height:26px;
margin:0;
position:absolute;
right:0;
padding:0 32px 0 6px
}
#search_form #search_holder #search_field{
z-index:3;
border:1px solid #C9C9C9;
background:url("") #fff;
-webkit-border-radius:5px;
-moz-border-radius:5px;
-o-border-radius:5px;
-ms-border-radius:5px;
border-radius:5px;
text-shadow:0 0 1px #fff
}
#search_form #search_holder #search_field:focus,#search_form #search_holder #search_field:hover{
border-color:#acb1b4;
color:#123
}
#search_form #search_holder #search_field:-moz-placeholder{
color:#a6a7a8
}
#search_form #search_holder #search_field::-webkit-input-placeholder{
color:#a6a7a8
}
#search_form #search_holder #search_field:-moz-placeholder{
color:#a6a7a8
}
#search_form #search_holder #search_suggest{
z-index:2;
border:none;
background:#fff;
border:1px solid #fff;
-webkit-border-radius:5px;
-moz-border-radius:5px;
-o-border-radius:5px;
-ms-border-radius:5px;
border-radius:5px;
color:#9da2a8
}
#search_form #search_holder .overTxtLabel{
z-index:113
}
#search_form .active{
color:#fff;
background:#a6a7a8
}
#search_form .btn_search{
z-index:3;
position:absolute;
top:4px;
right:1px;
display:block;
color:#a6a7a8;
width:28px;
height:21px;
font-size:17px;
line-height:21px;
text-align:center;
font-weight:400;
background:0 0;
border:0;
border-left:1px dotted #a6a7a8
}
#search_form .btn-anchor{
background:0 0;
border:0;
border-bottom:1px solid #ccc;
color:#666;
margin:0 10px;
font-size:10px;
padding-bottom:2px;
font-weight:400
}
#search_form.voicetron [name="q"]{
padding-right:34px;
width:170px;
line-height:17px
}
#search_form.voicetron .btn_search{
color:#71767a
}
You can use an input type of image as your submit button:
<input type="image" src="/my/image/location.png" />
Instead of styling up a submit button. As far as I know, the input type of image replicates the submit behaviour of a submit button.
Add this to btn_search iconify class of css and specify an image.
background: url("your_url.png") no-repeat scroll 0 0 transparent;
You have set input value="s" so change it to value="" and add background image for that button
#search_form.voicetron .btn_search{
color:#71767a;
background-image:url('http://findicons.com/files/icons/1389/g5_system/16/toolbar_find.png');
background-repeat:no-repeat;
}
Js Fiddle
You can simply treat the button as a block element and remove the text with
text-indent:-9999px;
then set a background image.
You probably also want to add
cursor:pointer;
As it doesn't look like a button at the moment.

Search Bar with background graphics

I have a search box like below and i am using bootstrap to give a flexible layout. How can use a design like below and make sure i can get a stretchable search box.
You'd need a container to put your input box in, and put a front and end div to it. Depending on browser compatibility you might want to add a few more div's to make sure your input box is shown properly in browsers like IEX7/8 though.
So you'd have the following:
<form class="searchbox">
<input type="text" class="text" />
<input type="submit" class="submit" />
</form>
Accompanied by the following example CSS
form.searchbox { background:url(leftside_image.gif) 0 0 no-repeat; padding-left:15px; }
form.searchbox input.text { border:none; border-top:1px solid #999; border-bottom:1px solid #999; height:25px; line-height:25px; padding:0 5px; }
form.searchbox input.submit { background:url(rightside_image.gif); }
Add your Html part like this
<div class="searchbox">
<input class="lightsearch" type="text" name="s" onfocus="doClear(this)" value="">
</div>
css part, download a search box image and replace it with the name
.searchbox input.lightsearch {
background: url("images/lightsearch.png") no-repeat scroll 0 0 transparent;
border: 0 none;
color: #575757;
font-size: 11px;
height: 19px;
margin-top: 24px;
padding: 2px 5px 2px 24px;
width: 170px;
}