Sticky Navbar

Permalink
Hi
I would really appreciate some help. I have a dropdown megamenu and I'm trying to make it stick to the top after scrolling. I've tried many instances of css and javascript but I just can't get it to work.
Many thanks if you can help.
I'm on Concrete5.8.4.2

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
.navbar {
  overflow: hidden;
  background-color: #fff;
  font-family: Arial, Helvetica, sans-serif;

tjbphoto
 
Steevb replied on at Permalink Reply
Steevb
You do not have anything ‘fixed’?
Use css:
.navbar{
position: fixed;
z-index: 3
}
tjbphoto replied on at Permalink Reply
tjbphoto
Hi Steevb

I've removed all the fixed, sticky and js as I can't get it to work. I've had it working without the dropdown but its a megamenu which is the whole point.

Many thanks for your help.
helvetica replied on at Permalink Reply
helvetica
this little script might help:
http://stickyjs.com/
easy to configurewith lots of options.
tjbphoto replied on at Permalink Reply
tjbphoto
Hi Helvetica
I've played with it but it keeps freezing the editing interface. Annoying to keep revising versions.
Thanks for your help, I will keep trying.
Steevb replied on at Permalink Reply 1 Attachment
Steevb
I set up a quick demo with css below:
.navbar {
 margin: 0;
  background-color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  position: fixed;
  width:100%;
  top:0;
  border-bottom: 1px solid #f00
}


See attached movie, if it uploads?
tjbphoto replied on at Permalink Reply
tjbphoto
Many thanks for that Steevb but I need it " stick " not fixed. The navbar has to ride over another element then stick to the top.
Where did you put the navbar btw. Mine breaks up ( its not in the autonav )
I think this will need js.
Tel
Steevb replied on at Permalink Reply
Steevb
tjbphoto replied on at Permalink Reply
tjbphoto
Well, That is very nice but it doesn't have a megamenu dropdown. That has been my problem.
Thanks Steevb
helvetica replied on at Permalink Reply
helvetica
1.) Copy jquery.sticky.min.js in your js folder.
2.) Make sure jquery.js is loaded.
3.) In the opening bracket of the header put:
<header id="fixed-header">


4.) In the footer, before the </body> closing bracket put:

<script src="<?php  echo $view->getThemePath()?>/js/jquery.sticky.min.js"></script>
<script> 
   $(document).ready(function(){
        $("#fixed-header").sticky({
            topSpacing:0,
          });
      });
</script>


That gives you a «sticky» header for your purpose. check stickyjs.com to see how to «unstick» at a desired position.