Skip to content

Instantly share code, notes, and snippets.

@mrkpatchaa
Created October 25, 2014 21:41
Show Gist options
  • Save mrkpatchaa/3e2c82485248fe2db65c to your computer and use it in GitHub Desktop.
Save mrkpatchaa/3e2c82485248fe2db65c to your computer and use it in GitHub Desktop.
How to Give Your Logo the “Slip Scroll” Effect
.container {
overflow: hidden;
position: relative;
min-height: 400px;
padding: 1em;
}
.dark {
background: #333;
}
.light {
background: #fff;
}
.default {
position: fixed;
}
.moveable {
position: absolute;
}
var setLogo = function() {
$('.moveable').each(function() {
$(this).css('top',
$('.default').offset().top -
$(this).closest('.container').offset().top
);
});
};
$(document).scroll(function() {
setLogo();
});
setLogo();
<div class="container dark">
<img src="img/acme-light.svg" class="default">
</div>
<div class="container light">
<img src="img/acme-dark.svg" class="moveable">
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="js/slip_scrol_effect.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment