Skip to content

Instantly share code, notes, and snippets.

@jdcauley
Created August 7, 2014 11:34
Show Gist options
  • Save jdcauley/af05d5750e44a285c288 to your computer and use it in GitHub Desktop.
Save jdcauley/af05d5750e44a285c288 to your computer and use it in GitHub Desktop.
style-to-head
function dribbleVideoPosition(){
if($('body').hasClass('home') ){
var currentWindow = $(window).width();
if (currentWindow < 1628){
var difference = 1628 - currentWindow;
var half = Math.round(difference/2);
var newMarginLeft = half;
var css = '.dribble{margin-left: -'+ newMarginLeft + 'px !important;}',
head = document.head || 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));
}
head.appendChild(style);
}
}
}
dribbleVideoPosition();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment