Created
April 12, 2017 15:27
-
-
Save ejke/dddf6ec7876343f584a8a1a34d7833f0 to your computer and use it in GitHub Desktop.
WP admin bar + sticky header
This file contains 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
.admin-bar .site-header { | |
top: 46px; | |
} |
This file contains 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
@media screen and ( min-width: 783px ) { | |
.admin-bar .site-header { | |
top: 32px; | |
} | |
} |
This file contains 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 $document = $(document), | |
$header = $('.admin-bar .site-header'); | |
if($(window).width() < 601) { | |
$document.scroll(function() { | |
if ($document.scrollTop() >= 46) { | |
// user scrolled 46 pixels or more; | |
$header.css({"top": "0"}) | |
} else { | |
$header.css({"top": "46px"}) | |
} | |
}); | |
} else { | |
//nothing | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment