Skip to content

Instantly share code, notes, and snippets.

@make-sum
make-sum / appendCSS
Created October 20, 2014 20:32
Append CSS with JS
var css = '@import url(http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,900,700,500,500italic,700italic,900italic);',
header = document.getElementsByTagName("head")[0],
style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
// http://www.smashingmagazine.com/2013/08/09/absolute-horizontal-vertical-centering-css
// center
.Absolute-Center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
// within container
/* ---------------------------------------------------------------------------
Boilerplate CSS Media Queries
Encoding: UTF-8
Author: PaulUnd (http://www.paulund.co.uk/boilerplate-css-media-queries)
--------------------------------------------------------------------------- */
/* =Smartphones (portrait and landscape)
--------------------------------------------------------------------------- */
@media only screen
@make-sum
make-sum / RTL Bootstrap flip via JS
Last active March 3, 2020 17:07
RTL and LTR direction change for Bootstrap using JavaScript i18N
// Eldar: https://stackoverflow.com/questions/19730598/right-to-left-support-for-twitter-bootstrap-3
// Edited for custom implementation
var layout = {};
layout.setDirection = function (direction) {
layout.rtl = (direction === 'rtl');
document.getElementsByTagName("html")[0].style.direction = direction;
var styleSheets = document.styleSheets;
var modifyRule = function (rule) {
@make-sum
make-sum / .block
Created November 8, 2017 08:21 — forked from mbostock/.block
Force Layout with Mouseover Labels
license: gpl-3.0