Skip to content

Instantly share code, notes, and snippets.

View floster's full-sized avatar

floster

  • Ukraine, Khmel'nyts'kyy
View GitHub Profile
@floster
floster / SCSS Mixins
Last active September 5, 2017 08:58
:placeholder SASS mixin
@mixin optional-at-root($sel) {
@at-root #{if(not &, $sel, selector-append(&, $sel))} {
@content;
}
}
@mixin placeholder {
@include optional-at-root('::-webkit-input-placeholder') {
@content;
}
@mixin clearfix() {
&:before,
&:after {
content: "";
display: table;
}
&:after {
clear: both;
}
}
// var height = (window.innerHeight > 0) ? window.innerHeight : screen.height;
// var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
$(function() {
$(window).on('load resize orientationchange', function() {
var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
if ( width <= 777 && width > 480 ) {
// do smthng
} else if ( width <= 480 ) {
// do smthng
$().ready(function () {
//we reconstruct menu on window.resize
$(window).on("resize", function (e) {
var parentWidth = $("#submenu-items-visible").parent().width() - 50;
var ulWidth = $("#submenu-items-hidden").outerWidth();
var menuLi = $("#submenu-items-visible > li");
var liForMoving = new Array();
//take all elements that can't fit parent width to array
menuLi.each(function () {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
position = $(window).scrollTop();
$('html, body').animate({
scrollTop: target.offset().top
}, 1000);
@floster
floster / gist:419d2d206f097cef840f
Created February 18, 2016 15:21
Vertical align with :after
.outer {
width: 200px;
height: 500px;
text-align: center;
background-color: #ffc;
}
.outer:after {
display: inline-block;
@floster
floster / tipsandtricks.css
Created January 4, 2016 07:55
vertical align with Flex
/* Vertical align */
.d-flex-vertical {
/* Tell flexbox to start vertically from the center */
align-items:center;
display:flex;
/* I'm also aligning it horizontally */
justify-content:center;
}
@floster
floster / helpers.html
Created December 3, 2015 08:37
html5shim
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
@floster
floster / snippets.js
Last active November 13, 2015 10:26
JSON "not well-formated"
$.ajaxSetup({ // if Firefox => JSON "not well-formated"
beforeSend: function(xhr){
if (xhr.overrideMimeType)
{
xhr.overrideMimeType("application/json");
}
}
});
@floster
floster / tipsandtricks.css
Created October 13, 2015 11:38
Centering in the Unknown
/* This parent can be any width and height */
.block {
text-align: center;
/* May want to do this if there is risk the container may be narrower than the element inside */
white-space: nowrap;
}
/* The ghost, nudged to maintain perfect centering */
.block:before {