-webkit-file-upload-button css implementation for firefox - css

I have css implementation for <input type="file"> which styles the button and this is my code:
::-webkit-file-upload-button {
cursor: pointer;
margin-top: 25px;
display: inline-block;
padding: 6px;
padding-right: 29px;
padding-left: 29px;
transition: all 1s ease;
color: #darkGray;
text-transform: capitalize;
font-size: 15px;
z-index: 1;
position: relative;
border-radius: 25px;
background-color: transparent;
border: 2px solid #red;
}
But this only works on Chrome and I would like to know how would I do it for other browsers?

There's a standard ::file-selector-button pseudo-element now, see https://github.com/w3c/csswg-drafts/issues/5049. Firefox supports it, and future versions of Safari and Chrome will too.

Here is how you can implement custom styling for the "file" input type: https://css-tricks.com/snippets/css/custom-file-input-styling-webkitblink/

Most people tell you to completely do away with the button stuff and use another button to engage the click(); function on the file chooser.
But that may soon be outdated wizardry, as you found out. The equivalent of what you are doing on IE (v10 and above) starts this way:
input[type="file"]::-ms-browse {
background-color: #ffffff00;
margin: 0px;
padding: 0px;
border: 0px;
}
input[type="file"]::-webkit-file-upload-button {
background-color: #ffffff00;
margin: 0px;
padding: 0px;
border: 0px;
}
<input type="file"/>
There are two most important reasons why you should continue to go with your direction
Less hackery, why make it hard if you can do it simpler nowadays?
On Chrome and FF, the file chooser becomes automatically a drop target, that adds huge usability value.
Now I am still researching how I can make the button 3d shading go away, so I can make the button invisible and leave only the simple drop target field.

Styling file inputs is notoriously difficult, as most browsers will not change the appearance from either css or javascript.
You can pass through click events from labels and style the label in whichever way you want.
<label id="add-computer-button" for="fileupload">Add from computer
<input id="fileupload" type="file" multiple="multiple" name="_photos" accept="image/*" style="visibility: hidden">
Here is the demo: https://jsfiddle.net/dinesh_feder/jww69rnf/

Related

Date Picker Selector for Input Field

I'm trying to change the color of the date picker that shows in some browsers but don't know the selector's name.
HTML:
<form action="pledge.html" method="post">
<input type="date" id="birthday" name="user_bday">
</form>
CSS:
body {
background-color: black;
}
input {
height: 45px;
width: 40%;
border-width: 3px;
border-style: solid;
border-color: white;
border-radius: 90px;
margin: 10px;
text-align: center;
font-size: 24px;
color: white;
font-weight: bold;
background-color: transparent;
outline: none;
}
input[type="date"] {
/*Something Goes Here Probably*/
}
Here's a fiddle
https://jsfiddle.net/froggomad/gznx60j1/25/
Thanks!
There are only 8 pseudo elements that are available for customization by default using webkit
::-webkit-datetime-edit
::-webkit-datetime-edit-fields-wrapper
::-webkit-datetime-edit-text
::-webkit-datetime-edit-month-field
::-webkit-datetime-edit-day-field
::-webkit-datetime-edit-year-field
::-webkit-inner-spin-button
::-webkit-calendar-picker-indicator
and sadly, there is no cross browser way of styling a native date picker.
your selector is okay.
input[type="date"] {
/*CSS Rules*/
}
If your codes run on one browser and don't run on another browser, then you need to write Cross Browser Supported Codes with the prefix such as -webkit- , -moz- etc.
But, I will suggest you to use https://jqueryui.com/datepicker/ for flexibility and more features.

CSS input field styling magic

I am trying to style an input field and some buttons in a consistent way, but there seems to be some magic going on. Event though the input has the exact same classes as the buttons it is slightly higher. Also the placeholder text is vertically aligned differently the the inputted text (one pixel higher). Can this be solved with a cross-browser solution?
Edit: As pointed out by Jan Turoň the line height fixed the problem in Webkit. Now, if you check the codepen in Firefox you'll notice that the element still has a 1px border. How to get rid of that?
Thx, PS
Codepen
HTML
<form action="">
Button
<input type="text" class="btn" placeholder="input"/>
<button class="btn">Login</button>
Button
</form>
CSS
.btn, input, button {
display: inline-block;
vertical-align: middle;
line-height: 15px;
font-size: 15px;
font-family: sans-serif;
border: 0;
padding: 0;
margin: 0;
cursor: pointer;
cursor: hand;
text-decoration: none;
color: #f2f2f2;
background-color: #1a1a1a;
padding: 7px 12px 8px 12px;
margin-right: 1px;
margin-bottom: 1px;
}
The line-height doesn't shrink the input height below font-size plus some pixels see the MDN info:
On replaced inline elements, like buttons or other input element, line-height has no effect.
Just remove the line-height and you should get what you want even without applying heightstyle. Setting line-height to 130% also does seem to work.
I am trying to solve this for days and every solution is not whole, and not working in different browsers.
I find that this code do the work:
float: left;
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
box-sizing:border-box;
height: 33px;
I have updated Codepen - http://codepen.io/anon/pen/pvqRwE

I can't remove the pressed effect of buttons in Internet Explorer 9

I'm trying to remove the pressed effect from button on IE9. In all other browsers I have no problems.
Please take a look to the code
HTML
<button class="fancy">howdy!</button>
CSS
.fancy {
width: 60px;
height: 30px;
position: relative;
top: 0px;
margin: 0;
padding: 0px;
display: block;
border: none;
padding: 0;
color: #FFF;
font-size: 11px;
background: green;
outline: none;
overflow: hidden;
line-height: 11px;
}
.fancy:active,.fancy:focus
{
padding:0px;
margin:0px;
border: none;
outline:none;
text-indent: 0;
line-height: 11px;
}
Working demo http://jsfiddle.net/MDfvE/
As you can see, when you click the button on IE9 you will see that the text is moved to the right and bottom. I want to remove that.
Any clue? Thank you!
IE only recognizes the :active pseudo class when the element is an anchor.
http://msdn.microsoft.com/en-us/library/cc848864%28v=VS.85%29.aspx
Try changing the button element to an anchor tag and adjust the styling to recreate the look you had for your button.
It's a browser behaviour, a simple solution is to use a link tag instead of button (if its triggering a javascript function).
<img src="myimg"/>
If you still want to use the <button>, I've found that there are some characteristics on each browser (in a simple debug):
Chrome adds outline and padding
Firefox adds a whole lot of stuff with the standart button border
IE messes with the inner text position
So to fix them, you have to manipulate the pseudo selectors for the button behaviour. And for IE, a good solution is to envolve your text on a element, and make it relative positioned. Like so:
<button type="button" class="button"><span>Buttom or Image</span></button>
<style>
button,
button:focus,
button:active{
border:1px solid black;
background:none;
outline:none;
padding:0;
}
button span{
position: relative;
}
</style>
Pen

Need Advice On Simple CSS Tooltip

I need some advice on a simple CSS tooltip. I have a calendar on a site that is rendered within a table. People can add events to this calendar. I have added CSS so that when you hover over a date, it will display the event, or events for that date. Within the table, I have this for each date cell with an "event":
<td class="eventDate" id="2011-08-24" title="2011-08-24">
24
<span class="tooltip">
<img class="infoImg" src="./images/info.png" width="16" height="16">
<i>Today's Events</i>:
<br>
• This is an event.
<span class="noOfDays">[ 3 days ]</span>
</span>
</td>
And, this is what I have for my CSS (found the technique via a Google search):
td.eventDate {
position: relative;
z-index: 24;
background-color: #afafaf;
color: #000;
padding: 2px 4px 2px 4px;
text-align: right;
font-size: 36px;
font-family: Georgia;
}
td.eventDate:hover {
z-index: 25;
cursor: default;
}
td.eventDate span.tooltip {
display: none;
}
td.eventDate:hover span.tooltip {
display: block;
position: absolute;
top: 5.3em;
left: 28.5em;
width: auto;
color:#3e3e3e;
border:1px solid #3e3e3e;
background-color: #efefef;
padding: 4px 8px 4px 8px;
font-family: Candara, Tahoma, Geneva, sans-serif;
font-size: .4em;
font-weight: 700;
text-align: left;
z-index: 100;
}
span.noOfDays {
font-size: 11px;
padding: 0px 0px 0px 6px;
}
This works perfectly for any Mozilla based web browser; however, when I move to Safari, Chrome or IE (I haven't tried it in Opera yet), it is all wonky. For one thing. the size of the tooltip box seems constrained to the size of the table cell, making my events wrap all over the place. Also, the positioning of the tooltip box when it is "revealed" seems relative to the table cell in which the event span is placed, and not aligned with the top-right of the calendar table.
Can anybody see what I am doing wrong? Should this not be working in Mozilla either? Are there any other very simple, and lightweight tooltip techniques I can use that you would suggest? I was trying to stay away from JavaScript/JQuery/etc. as I wanted to keep this pretty light, but I may have to switch over if I cannot get this to work with CSS. Any, and all advice is appreciated.
Thanks for taking the time to read, and have a great day. :-)
Why not use a simple jquery tooltip script. easy to implement and will be set up under 1 minute.
try Tiptip or Qtip in google. Will safe you some time

Flexible CSS button (variable width and markup)

I'm trying to create a flexible CSS button, styled with only one image (or two, using the sliding door technique) but i want it to be flexible enough for multiple markup to have the same effect. For example:
Button
Would have the save effect as:
<input type="submit" value="Button" />
Any ideas or tuts laying around?
I don't think you can apply the sliding door technique to input elements. When I did it I used the button element:
<button type="submit"><span>Button</span></button>
You'd have to watch out with IE because it's a bit buggy (submitting the content of the button instead of it's value and when you have multiple submit buttons in a form submitting all buttons instead of the clicked one), but these cases are usually rare.
For a link I used:
<span>Link</span>
And the approximate CSS:
a.button,
button {
color: #ffffff;
background: transparent url(right.png) no-repeat top right;
font-weight: bold;
text-decoration: none;
text-align: center;
border: none;
padding: 0 8px 0 0;
margin: 1px 0;
height: 20px;
overflow: visible;
cursor: pointer;
}
a.button::-moz-focus-inner,
button::-moz-focus-inner {
border: none;
}
a.button:focus,
button:focus {
outline: 1px dotted buttontext;
}
a.button span,
button span {
background: transparent url(left.png) no-repeat top left;
padding: 2px 0 4px 8px;
display: block;
}
If you want to use sliding doors, you can just add an element around the <input/>, right?
There's no pure CSS solutions to making a link submit, the only things in HTML that can submit are input elements, so you're stuck using <input type="button" /> and <input type="image" />.
I would use the Jquery submit event
So..
$('#my_button').click(function() {
$(this).submit();
});
If you do not understand Jquery this will not make any sense.

Resources