Day24-sticky Nav

Source: Internet
Author: User

This article originates from: Chun elder brother personal blog: http://www.liyuechun.org
Author: © Li Yue Chun-the person chasing time
Synopsis: JavaScript30 is a 30 day challenge from Wes Bos. The project offers 30 video tutorials, 30 challenge starter documents, and 30 Challenge solution source code free of charge. The goal is to help people write with pure JavaScript, without using frames and libraries, and without compilers and references. Now you see the 24th article in this series of guides. Complete Chinese version of the Guide and video tutorials on the entire stack from zero to one tribe. Effect Chart

The 24th day of training is to do a slide down to the navigation bar to make it a fixed style. This style in daily life is a very common effect, in order to users in the content of the decline can be faster to jump to their own needs of other content, the site will generally add this effect, user-friendly user for faster page navigation. HTML Source

<! DOCTYPE html>  
 CSS Source code   
HTML {box-sizing:border-box;
  Background: #eeeeee;
  font-family: ' Helvetica Neue ';
  font-size:20px;
font-weight:200;

} body {margin:0;}

*, *:before, *:after {box-sizing:inherit;}
  . site-wrap {max-width:700px;
  margin:70px Auto;
  Background:white;
  padding:40px;
  text-align:justify;
  box-shadow:0 0 10px 5px rgba (0, 0, 0, 0.05);
  Transform:scale (0.98);
Transition:transform 0.5s;

}. Fixed-nav. site-wrap {Transform:scale (1);}
  header {Text-align:center;
  HEIGHT:50VH;
  Background:url (http://wes.io/iEgP/wow-so-deep.jpg) bottom center no-repeat;
  Background-size:cover;
  Display:flex;
  Align-items:center;
Justify-content:center;
  } h1 {Color:white;
  FONT-SIZE:7VW;
  text-shadow:3px 4px 0 rgba (0, 0, 0, 0.2)} nav {background:black;
  top:0;
  width:100%;
  Transition:all 0.5s;
  position:relative;
Z-index:1;
  }. Fixed-nav nav {position:fixed;
box-shadow:0 10px 10px rgba (0, 0, 0, 0.2); } Nav ul {margin: 0;
  padding:0;
  List-style:none;
Display:flex;
  } nav li {flex:1;
  Text-align:center;
  Display:flex;
  Justify-content:center;
Align-items:center;
  } li.logo {max-width:0;
  Overflow:hidden;
  Background:white;
  Transition:all 5s;
  font-weight:600;
font-size:30px;

}. Fixed-nav Li.logo {max-width:500px;}

Li.logo a {color:black;} Nav

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.