vOGQrZ ('-' * 6)
A Pen by Miles Smith on CodePen.
<section class="gallery"> | |
<div class="followMeBar header bleeder"> | |
<h2>Hello</h2> | |
</div> | |
<div class="bleeder dark"> | |
<figure class="leader"> | |
<figcaption> | |
<div class="holder"> | |
<div class="words"> | |
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. | |
</div> | |
</div> | |
</figcaption> | |
<img src="http://cache3.asset-cache.net/gc/467964512-nickelodeons-28th-annual-kids-choice-awards-gettyimages.jpg?v=1&c=IWSAsset&k=2&d=GkZZ8bf5zL1ZiijUmxa7QRZfma9bcmfOrKs2WXsRFDRBtsitoaEp6UQZWURxAPsr9wDtP2ie2ZV1jZthKlMQVeOD6%2f0vC4C%2fWWjRYQyN1qA%3d" /> | |
</figure> | |
</div> | |
<figure class="left"> | |
<figcaption>caption b</figcaption> | |
<img src="x" /> | |
</figure> | |
<figure class="right"> | |
<figcaption> | |
<div class="holder"> | |
<div class="words"> | |
caption c<br>c<br>c<br>c<br>c<br>c<br>c | |
</div> | |
</div> | |
</figcaption> | |
<img src="x" /> | |
</figure> | |
<figure> | |
<figcaption>caption d</figcaption> | |
<img src="http://delivery.candidate-gettyimages.com/gc/113244528-grand-prix-of-great-britain-gettyimages.jpg?v=1&c=IWSAsset&k=2&d=lGnjDs01aeQKqjld9R%2fRads8JvZCn7v3SbokqFwY5zsYH8Of2qoae6GC0qnrgzDAbDOf%2bLkEbL39HccXLF2LdQ%3d%3d" /> | |
</figure> | |
<figure> | |
<figcaption>caption e</figcaption> | |
<img src="x" /> | |
</figure> | |
</section> | |
<section class="gallery"> | |
<div class="followMeBar bleeder"> | |
<h2>Moop</h2> | |
</div> | |
<div class="bleeder dark"> | |
<figure class="leader"> | |
<figcaption> | |
<div class="holder"> | |
<div class="words"> | |
caption a<br>c<br>c<br>c<br>c<br>c<br>c | |
</div> | |
</div> | |
</figcaption> | |
<img src="x" /> | |
</figure> | |
</div> | |
<figure class="left"> | |
<figcaption>caption b</figcaption> | |
<img src="x" /> | |
</figure> | |
<figure class="right"> | |
<figcaption> | |
<div class="holder"> | |
<div class="words"> | |
caption c<br>c<br>c<br>c<br>c<br>c<br>c | |
</div> | |
</div> | |
</figcaption> | |
<img src="x" /> | |
</figure> | |
<figure> | |
<figcaption>caption d</figcaption> | |
<img src="x" /> | |
</figure> | |
<figure> | |
<figcaption>caption e</figcaption> | |
<img src="x" /> | |
</figure> | |
</section> | |
<section class="gallery"> | |
<div class="followMeBar bleeder"> | |
<h2>Deeeeeerp</h2> | |
</div> | |
<div class="bleeder dark"> | |
<figure class="leader"> | |
<figcaption> | |
<div class="holder"> | |
<div class="words"> | |
caption a<br>c<br>c<br>c<br>c<br>c<br>c | |
</div> | |
</div> | |
</figcaption> | |
<img src="x" /> | |
</figure> | |
</div> | |
<figure class="left"> | |
<figcaption>caption b</figcaption> | |
<img src="x" /> | |
</figure> | |
<figure class="right"> | |
<figcaption> | |
<div class="holder"> | |
<div class="words"> | |
caption c<br>c<br>c<br>c<br>c<br>c<br>c | |
</div> | |
</div> | |
</figcaption> | |
<img src="x" /> | |
</figure> | |
<figure> | |
<figcaption>caption d</figcaption> | |
<img src="x" /> | |
</figure> | |
<figure> | |
<figcaption>caption e</figcaption> | |
<img src="x" /> | |
</figure> | |
</section> |
function stickyTitles(stickies) { | |
// this would probably work in iframes if it didnt bind to window... | |
var thisObj = this; | |
thisObj.load = function() { | |
stickies.each(function(){ | |
var thisSticky = jQuery(this).wrap('<div class="followWrap" />'); | |
thisSticky.parent().height(thisSticky.outerHeight()); | |
jQuery.data(thisSticky[0], 'pos', thisSticky.offset().top); | |
}); | |
jQuery(window).off("scroll.stickies").on("scroll.stickies", function() { | |
thisObj.scroll(); | |
}); | |
} | |
thisObj.scroll = function() { | |
stickies.each(function(i){ | |
var thisSticky = jQuery(this), | |
nextSticky = stickies.eq(i+1), | |
prevSticky = stickies.eq(i-1), | |
pos = jQuery.data(thisSticky[0], 'pos'); | |
if (pos <= jQuery(window).scrollTop()) { | |
thisSticky.addClass("fixed"); | |
if (nextSticky.length > 0 && thisSticky.offset().top >= jQuery.data(nextSticky[0], 'pos') - thisSticky.outerHeight()) { | |
thisSticky.addClass("absolute").css("top", jQuery.data(nextSticky[0], 'pos') - thisSticky.outerHeight()); | |
} | |
} else { | |
thisSticky.removeClass("fixed"); | |
if (prevSticky.length > 0 && jQuery(window).scrollTop() <= jQuery.data(thisSticky[0], 'pos') - prevSticky.outerHeight()) { | |
prevSticky.removeClass("absolute").removeAttr("style"); | |
} | |
} | |
}); | |
} | |
} | |
jQuery(document).ready(function(){ | |
new stickyTitles(jQuery(".followMeBar")).load(); | |
}); |
body { | |
margin: 0; | |
font-family: "HelveticaNeue"; | |
font-size: 12px; | |
line-height: 18px; | |
box-sizing: border-box; | |
} | |
$site_width: 830px; | |
.gallery { | |
border: 1px solid blue; | |
border-top: none; | |
width: $site_width; | |
margin: 0 auto; | |
.bleeder { | |
background-color: seagreen; | |
position: relative; | |
left: calc((100vw - 100%) / 2 - (100vw - 100%)); | |
padding-left: calc((100vw - 100%) / 2); | |
padding-right: calc((100vw - 100%) / 2); | |
width: $site_width; | |
&.dark { | |
background-color: rgba(100, 50, 25, 0.3); | |
} | |
} | |
h2 { | |
color: white; | |
margin: 0; | |
padding: 16px 0; | |
margin-left: 40px; | |
margin-right: 40px; | |
} | |
figure { | |
position: relative; | |
margin: 0 40px; | |
margin-bottom: 5vh; | |
background-color: goldenrod; | |
figcaption { | |
position: absolute; | |
top: 50%; | |
transform: translateY(-50%); | |
margin-left: 0; | |
width: 40%; | |
background-color: rgba(35, 31, 32, 0.6); | |
color: white; | |
padding: 30px; | |
} | |
img { | |
background-color: green; | |
color: green; | |
min-height: 250px; | |
display: block; | |
margin: 0 auto; | |
} | |
.leader { | |
margin-top: 0; | |
margin-bottom: 0; | |
} | |
&.left { | |
background-color: inherit; | |
img { | |
width: 50%; | |
margin: 0; | |
} | |
figcaption { | |
margin-left: 60%; | |
width: 30%; | |
background-color: inherit; | |
color: #666; | |
} | |
} | |
&.right { | |
background-color: inherit; | |
img { | |
width: 50%; | |
margin: 0; | |
margin-left: 50%; | |
} | |
figcaption { | |
margin-left: 10%; | |
width: 30%; | |
background-color: inherit; | |
color: #666; | |
} | |
} | |
} | |
} | |
.followMeBar.fixed { | |
position: fixed; | |
top: 0; | |
box-sizing: border-box; | |
z-index: 500; | |
padding: 0 calc((100vw - #{$site_width}) / 2); | |
background-color: seagreen; | |
width: 100%; | |
} | |
.followMeBar.fixed.absolute { | |
position: absolute; | |
} |
vOGQrZ ('-' * 6)
A Pen by Miles Smith on CodePen.