Menu icon Foundation
Sticky title bar troubles

Hey everyone,

so I just got back into doodeling around with foundation a bit and I keep running into a strange behavior when I want to set up a sticky title-bar. I'm working with this mint-condition new project called "test" where I didn't even touch the sass yet. The structure goes something like this:

<html class="no-js" lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Foundation for Sites</title>
  <link rel="stylesheet" href="css/app.css">
</head>

<body>


<div data-sticky-container>
  <div class="title-bar" data-sticky data-options="marginTop:0" style="width:100%">
    <div class="title-bar-left"><ul class="menu">
      <li><a href="#">Text</a></li>
      <li><a href="#">Text</a></li>
      <li><a href="#">Text</a></li>
    </ul></div>
    <div class="title-bar-right"><ul class="menu">
      <li><a href="#">Text</a></li>
      <li><a href="#">Text</a></li>
      <li><a href="#">Text</a></li>
    </ul></div>
  </div>
</div>


  <div class="callout large primary">
    <div class="row column text-center">
      <h1>Our Blog</h1>
<!-- and so on with the basic template -->

I run this in firefox and obtain a beautiful, responsive head menu (1). However, if I scroll down the page a bit and then back up to the beginning position, it just rips the whole thing apart  (2) :( so where did I go wrong? Obviously I just copy-pasted some code from the sticky-documentation into a premade template, so what did I miss?

 

(1) http://awesomescreenshot.com/00b5q47l19

(2) http://awesomescreenshot.com/0f25q47mbe

stickytitle-bargap

Hey everyone,

so I just got back into doodeling around with foundation a bit and I keep running into a strange behavior when I want to set up a sticky title-bar. I'm working with this mint-condition new project called "test" where I didn't even touch the sass yet. The structure goes something like this:

<html class="no-js" lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Foundation for Sites</title>
  <link rel="stylesheet" href="css/app.css">
</head>

<body>


<div data-sticky-container>
  <div class="title-bar" data-sticky data-options="marginTop:0" style="width:100%">
    <div class="title-bar-left"><ul class="menu">
      <li><a href="#">Text</a></li>
      <li><a href="#">Text</a></li>
      <li><a href="#">Text</a></li>
    </ul></div>
    <div class="title-bar-right"><ul class="menu">
      <li><a href="#">Text</a></li>
      <li><a href="#">Text</a></li>
      <li><a href="#">Text</a></li>
    </ul></div>
  </div>
</div>


  <div class="callout large primary">
    <div class="row column text-center">
      <h1>Our Blog</h1>
<!-- and so on with the basic template -->

I run this in firefox and obtain a beautiful, responsive head menu (1). However, if I scroll down the page a bit and then back up to the beginning position, it just rips the whole thing apart  (2) :( so where did I go wrong? Obviously I just copy-pasted some code from the sticky-documentation into a premade template, so what did I miss?

 

(1) http://awesomescreenshot.com/00b5q47l19

(2) http://awesomescreenshot.com/0f25q47mbe

Adam over 3 years ago

Hey mate,

Try changing this:

<div class="title-bar" data-sticky data-options="marginTop:0" style="width:100%">

to this:

<div class="title-bar" data-sticky data-options="anchor: page; marginTop: 0; stickyOn: small;" style="width:100%">

 

Philipp Jung over 3 years ago

Hey Adam,

thanks a million for your post here and in Vlad's thread! I could find the solution thanks to your code. I had a structure like this

<div class "title-bar-container" data-sticky-container>
  <div class="title-bar" data-sticky data-options="marginTop: 0;" style="width:100%">
title-bar-left, right, whatnot
</div>
</div>

which does not work. You need to rename the class "title-bar" into "sticky" and nest a new class "title-bar" into the other two, like this

<div class "title-bar-container" data-sticky-container>
  <div class="sticky" data-sticky data-options="anchor: page; marginTop: 0; stickyOn: small;" style="width:100%">
    <div class="title-bar">
      <div class="title-bar-left"><ul class="menu">
        <li><a href="#">Text</a></li>
        <li><a href="#">Text</a></li>
        <li><a href="#">Text</a></li>
      </ul></div>
      <div class="title-bar-right"><ul class="menu">
        <li><a href="#">Text</a></li>
        <li><a href="#">Text</a></li>
        <li><a href="#">Text</a></li>
      </ul></div>
    </div>
  </div>
</div>

 

Which means by the way that the documentation for sticky is outdated. All glory belongs to Adam, thanks again and have a nice week!