GithubHelp home page GithubHelp logo

rectorliu / animated-sticky-header Goto Github PK

View Code? Open in Web Editor NEW

This project forked from solodev/animated-sticky-header

0.0 1.0 0.0 4 KB

An animated sticky header helps maintain design integrity as your website loads, and yet preserves needed space while providing essential navigation options as a given user scrolls down the page.

HTML 42.28% CSS 54.28% JavaScript 3.44%

animated-sticky-header's Introduction

animated-sticky-header

An animated sticky header helps maintain design integrity as your website loads, and yet preserves needed space while providing essential navigation options as a given user scrolls down the page.

A little use of CSS3 transitions provides the subtle animations that interconnect the two header viewpoints. With some additional responsive styling, you'll have a contemporary animated sticky header.

Tutorial

For detailed instructions, view Solodev's Create an Animated Sticky Header article.

Demo

Try out a working example on JSFiddle.

HTML

The animated sticky header contains the following basic HTML markup:

<header>
  <nav class="navbar navbar-default navbar-fixed-top">

    <div class="navbar-header">
      <div class="container">
        <a class="navbar-brand" href="#">
           <img src="https://www.solodev.com/assets/side-nav/logo.png" alt="Logo Solodev">
        </a>
                        
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
                        
          </div>
        </div>
        
    <div id="navbar" class="navbar-collapse collapse navbar-right">
      <div class="container">
        <ul class="nav navbar-nav">
          <li><a href="#">Home</a></li>
          <li><a href="#about">About</a></li>
                        <li><a href="#services">Services</a></li>
          <li><a href="#contact">Contact</a></li>
        </ul>
                <ul class="social">
                  <li><a href="#"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
                  <li><a href="#"><i class="fa fa-twitter" aria-hidden="true"></i></a></li>
                  <li><a href="#"><i class="fa fa-linkedin" aria-hidden="true"></i></a></li>
                </ul>
          </div>
    </div><!--/.nav-collapse -->

                  
  </nav>
</header>

<div style="display: block; margin: 0 auto; text-align: center;">
  <img class="img-responsive" src="https://www.solodev.com/assets/hero/large-image.jpg">
</div>

CSS

All required CSS can be found in animated-sticky-header.css

JS

All needed JS is below:

$(window).scroll(function() {
    if ($(this).scrollTop() > 1){  
        $('header').addClass("sticky");
    }
    else{
        $('header').removeClass("sticky");
    }
});

External Includes

This tutorial contains the following third party resources.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="animated-sticky-header.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="animated-sticky-header.js"></script>

animated-sticky-header's People

Contributors

smmadara avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.