Skip to content

Instantly share code, notes, and snippets.

@alizhdanov
alizhdanov / main.js
Created August 13, 2016 09:11
Cross browser solution to find page height in Javascript
var scrollHeight = Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
);
@alizhdanov
alizhdanov / gist:5b4c1c6ef49f365db98ffa10e71f0911
Created May 13, 2016 14:40
Strict checking if it's number
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
@alizhdanov
alizhdanov / gist:f51753430ec3a04f6f8d
Created March 8, 2016 12:01
<wbr> substitution with old browser support
&shy;
example:
text&shy;text&shy;text&shy;
thanks http://www.quirksmode.org/oddsandends/wbr.html
@alizhdanov
alizhdanov / gist:d3bfd1027930566775b6
Created March 5, 2016 13:32
Form select customize
$('select').each(function(){
var $this = $(this),
numberOfOptions = $(this).children('option').length;
$this.addClass('select-hidden'); // скрываем селект
$this.wrap('<div class="select"></div>'); // оборачиваем селект в див
$this.after('<div class="select-styled"></div>'); // после селекта добавляем класс который иммитирует сам селект
var $styledSelect = $this.next('div.select-styled'); // выбираем иммитирующий селект блок
$styledSelect.text($this.children('option').eq(0).text()); // добавляем ему текст от первого option'a
/* ----------------------------------------------------------------------------------------------------
Super Form Reset
A couple of things to watch out for:
- IE8: If a text input doesn't have padding on all sides or none the text won't be centered.
- The default border sizes on text inputs in all UAs seem to be slightly different. You're better off using custom borders.
- You NEED to set the font-size and family on all form elements
- Search inputs need to have their appearance reset and the box-sizing set to content-box to match other UAs
- You can style the upload button in webkit using ::-webkit-file-upload-button
- ::-webkit-file-upload-button selectors can't be used in the same selector as normal ones. FF and IE freak out.
- IE: You don't need to fake inline-block with labels and form controls in IE. They function as inline-block.
/* Base */
body {
color: green;
font-family: "Georgia", serif;
font-size: 24px;
line-height: 1.5;
}
[role="button"],
input[type="submit"],