Skip to content

Instantly share code, notes, and snippets.

View pzi's full-sized avatar
🇨🇭
Grüessech

Patrik Affentranger pzi

🇨🇭
Grüessech
View GitHub Profile
@pzi
pzi / custom_select.coffee
Last active December 14, 2015 07:49
This script provides a workaround to apply custom style to a SELECT element. It dynamically wraps the targeted SELECT in a DIV and adds a SPAN element positioned absolutely after/below the SELECT element. This SPAN element then gets the selected option text. The SELECT will get opacity set to zero, so it is not visible but clickable. Since the S…
$.fn.customSelect = ->
$(this).filter('select').each (i) ->
$select = $(this)
# make sure we only apply once, no matter how many times called with the same selector
return if $select.data('customSelect')
$select.data('customSelect', true)
title = $select.find('option:first').text()
@pzi
pzi / input_file.css
Created February 20, 2013 06:34
Style input type="file" in Webkit (Chrome, Safari)
input[type=file] {
position: relative;
-webkit-appearance: textfield;
-webkit-box-sizing: border-box;
}
input[type=file]::-webkit-file-upload-button {
border: none;
margin: 0;
padding: 0;