This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin arrow($dir: 'down', $size: 4px, $color: #000) { | |
width: 0; | |
height: 0; | |
border-style: solid; | |
border-color: transparent; | |
@if ($dir == 'up' or $dir == 'down') { | |
border-left-width: $size; | |
border-right-width: $size; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin placeholder() { | |
&::-webkit-input-placeholder { | |
@content; | |
} | |
&:-moz-placeholder { /* Firefox 18- */ | |
@content; | |
} | |
&::-moz-placeholder { /* Firefox 19+ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Проверка числа | |
var isNumber = function(num) { | |
// Функция parseInt вовращает число или NaN | |
// NaN будет возвращено, когда невозможно привести num к числу, | |
// например, parseInt('j23'), parseInt({}), parseInt(['a', 2, 3]) | |
// число вернется, когда parseInt сможет преобразовать num к числу, | |
// например, parseInt('12string'), parseInt(12), parseInt([12, 13, 14]) | |
// всё это вернет число 12 | |
if (isNaN(parseInt(num))) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Использйте универсальный селектор | |
для быстрой отладки лэйаутов | |
*/ | |
body * { | |
/* | |
Можно использовать свойство background-color | |
c определенной прозрачностью | |
*/ | |
background-color: rgba(0,0,0, .05); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Используйте метод массивов filter, | |
// чтобы удалить все ложные свойства из массива | |
var arr = ['', 1, 'str 1', 0, false, 'str 2', null]; | |
// Функция Boolean() возвращает только значения true и false | |
arr.filter(Boolean); // [1, 'str1', 'str 2'] | |
// Сокращенный вариант функции | |
arr.filter(function(item) { | |
return !!item; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin arrow($dir: 'down', $size: 4px, $color: #000) { | |
width: 0; | |
height: 0; | |
border-style: solid; | |
border-color: transparent; | |
@if ($dir == 'up' or $dir == 'down') { | |
border-left-width: $size; | |
border-right-width: $size; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Чтобы создать список, разделенный запятыми, | |
ul > li { | |
// достаточно присвоить всем элементам li свойство display: inline | |
display: inline; | |
// и добавить запятую после каждого элемента в списке, | |
// кроме последнего, с помощью after | |
&:not(:last-child)::after { | |
content: ','; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Для отображения внешних ссылок, не содежащих текст, | |
// например, <a href="http://vk.com"></a> | |
// можно использовать функцию attr() для заполнения | |
// ссылки текстом | |
a[href^="http"]:empty::before { | |
content: attr(href); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function(window){ | |
var S = function(selector, context) { | |
return new DOM(selector, context); | |
}; | |
var DOM = function(selector, context) { | |
var currentContext = document; | |
if (context) { | |
if (context.nodeType) { | |
currentContext = context; |
OlderNewer