Skip to content

Instantly share code, notes, and snippets.

@pochi-web pochi-web/header.php
Last active Nov 10, 2017

Embed
What would you like to do?
header.php
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title><?php echo the_title();?></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php wp_enqueue_script("jquery");?>
<?php wp_head();?>
<script>
var j = jQuery.noConflict();
j(window).on('scroll',function(){
var j = jQuery.noConflict();
var $bodyWidth = j('body').outerWidth();
var $footerWidth = j('footer').outerWidth();
var $setMargin = ($bodyWidth - $footerWidth)/2;
var $bodyHeight = j('body'). outerHeight(true);
var $scrolled = j(window).scrollTop();
var $windowHeight = j(window).height();
var $xHeight = $scrolled+$windowHeight;
if($bodyHeight === $xHeight){
j('footer').css('margin-bottom',$setMargin);
}else{
j('footer').css('margin-bottom','0');
}
})
</script>
</head>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.