Skip to content

Instantly share code, notes, and snippets.

/* Base */
body {
color: green;
font-family: "Georgia", serif;
font-size: 24px;
line-height: 1.5;
}
[role="button"],
input[type="submit"],
/* ----------------------------------------------------------------------------------------------------
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.
@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
@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
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
@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);
}
@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 / scrollTop.js
Created August 21, 2016 20:03
pure javascript scrollTop function
function scrollTo(element, to, duration) {
if (duration < 0) return;
var difference = to - element.scrollTop;
var perTick = difference / duration * 2;
setTimeout(function() {
element.scrollTop = element.scrollTop + perTick;
scrollTo(element, to, duration - 2);
}, 10);
}
@alizhdanov
alizhdanov / app.js
Last active November 8, 2016 09:13
Moving body background
// single-line solution
$('body').css('background-position', 'center ' + (-window.pageYOffset / 8) + 'px');
// more advanced solution
$('.paralax').each(function() {
var position = (-window.pageYOffset) + $(this).offset().top
position = -(position / 8)
if (position >= ($(this).height() + $(this).height() / 2)) {
gulp.task('images-webp', function () {
return gulp.src('./public/assets/img/**/*.{jpg,png}')
.pipe(webp())
.pipe(gulp.dest('./public/assets/img/'))
.pipe(gulp.dest('./public/assets/img/'));
});
gulp.task('images-webp-posts', function () {
return gulp.src('./public/files/post/**/*.{jpg,png}')
.pipe(webp())