SOURCE

console 命令行工具 X clear

                    
>
console
$(document).ready(function($) {
$('.header').after($("b").clone().find('.header').attr('class','header-mobile'));
  // 手机导航
  $('.menuBtn').append('<b></b><b></b><b></b>');
  $('.menuBtn').click(function(event) {
    $(this).toggleClass('open');
    $('.hdr').stop().slideToggle();
  });

  var _winw = $(window).width();
  if (_winw > 959) {
    //     pc 端导航鼠标经过的时候弹出
    $('.nav li').hover(function() {
      $(this).find('.sub').stop().slideDown();
      if ($(this).find('.sub').length) {
        $(this).addClass('ok');
        $('.header').addClass('on');
      } else {
        $('.header').removeClass('on');
      }
    },
    function() {
      $(this).removeClass('ok');
      $(this).find('.sub').stop().slideUp();
    });

    $('.nav').mouseleave(function(event) {
      if ($('.header').hasClass('on')) {
        $('.header').removeClass('on');
      };
    });

    // 头部悬浮高度变化
    $(window).scroll(function() {
      var _winw2 = $(window).width();
      if ($(window).scrollTop() >= 10 && _winw2 > 959) {
        $(".header").addClass('min');

      } else {
        $(".header").removeClass('min');
      }
    });

  } else {
    //     手机端导航鼠标点击的时候弹出
    $('.nav .v1').click(function() {
      if ($(this).siblings('.sub').length) {
        $(this).parents('li').siblings('li').find('.sub').stop().slideUp();
        $(this).siblings('.sub').stop().slideToggle();
        return false;
      }
    });
  }

  //   搜索只在pc端弹出
  if (_winw > 959) {

    $('.so').hover(function() {
      $(this).toggleClass('so-on');
      $(this).find('.so-box').stop().slideToggle();

    });
  }

  // 窗口切换的时候事件的处理

});
<script src="https://cdn.bootcss.com/jquery/2.2.2/jquery.min.js">
</script>
<link href="https://cdn.bootcss.com/minireset.css/0.0.2/minireset.min.css"
rel="stylesheet">
<div class="header">
  <span class="menuBtn">
  </span>
  <div class="wp">
    <div class="logo">
      <a href="/">
        <img src="http://www.5811.com.cn/images/logo2.png" alt="" />
      </a>
    </div>
    <div class="logo logo1">
      <a href="/">
        <img src="http://www.5811.com.cn/images/logo2.png" alt="" />
      </a>
    </div>
    <div class="hdr">
      <ul class="nav">
        <li class="on">
          <a href="/" class="v1">
            首页
          </a>
        </li>
        <li>
          <a href="" class="v1">
            关于我们
          </a>
          <div class="sub">
            <a href="">
              公司简介
            </a>
            <a href="">
              组织架构
            </a>
            <a href="">
              客户案例
            </a>
            <a href="">
              联系我们
            </a>
          </div>
        </li>
        <li>
          <a href="" class="v1">
            产品与服务
          </a>
          <div class="sub">
            <a href="/index.php?c=article&a=type&tid=62">
              线上健康管理
            </a>
            <a href="/index.php?c=article&a=type&tid=63">
              社区智能健康中心
            </a>
            <a href="/index.php?c=article&a=type&tid=64">
              线下活动
            </a>
            <a href="/index.php?c=article&a=type&tid=65">
              健康指南
            </a>
          </div>
        </li>
        <li>
          <a href="/index.php?c=article&a=type&tid=66" class="v1">
            新闻报道
          </a>
          <div class="sub">
            <a href="/index.php?c=article&a=type&tid=66">
              公司新闻
            </a>
            <a href="/index.php?c=article&a=type&tid=71">
              行业新闻
            </a>
          </div>
        </li>
        <li>
          <a href="/index.php?c=article&a=type&tid=67" class="v1">
            加入我们
          </a>
          <div class="sub">
            <a href="/index.php?c=article&a=type&tid=67">
              人才招聘
            </a>
            <a href="/index.php?c=article&a=type&tid=68">
              企业责任
            </a>
          </div>
        </li>
      </ul>
      <div class="so">
        <span class="so-btn">
        </span>
        <form action="/index.php" method="get">
          <div class="so-box">
            <input name="a" type="hidden" value="search" />
            <input type="hidden" name="c" value="article" />
            <input type="text" name="word" class="inp" style="font-size:12px;" />
            <input type="submit" class="btn" value="" />
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
<div style="height:2000px;padding-top:200px;">
  测试滚动的时候导航高度会有变化
</div>
/* 公用样式 */

body {
  font-family: "微软雅黑";
}

a {
  color: #000;
  text-decoration: none;
}

.wp {
  margin: 0 auto;
  width: 100%;
  max-width: 1200px
}


/* 头部开始 */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  background-color: rgba(255, 255, 255, .8);
  background-color: rgb(255, 255, 255)\9;
  z-index: 9;
  -webkit-transition: .3s;
  -o-transition: .3s;
  transition: .3s;
  box-shadow: 0px 2px 10px rgba(0, 0, 0, .1);
}

.header .wp,
.logo a {
  height: 100%;
}

.logo {
  max-width: 260px;
  height: 100%;
  float: left;
  line-height: 120px;
}

.logo img {
  display: inline-block;
  vertical-align: middle;
  max-height: 60%;
  width: auto;
  max-width: none;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -ms-backface-visibility: hidden;
  backface-visibility: hidden;
}

.logo1 {
  display: none;
}

.logo1 img {
  height: 23px;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -ms-backface-visibility: hidden;
  backface-visibility: hidden;
}

.hdr {
  float: right;
  height: 100%;
}

.nav {
  float: left;
  overflow: hidden
}

.nav li {
  float: left
}

.nav li>a {
  font-weight: 700;
  display: block;
  line-height: 120px;
  width: 110px;
  text-align: center;
  margin: 0 10px;
}

.nav li.on>a {
  background-color: #757cbb;
  color: #fff!important
}

.nav li.ok>a {
  color: #757cbb;
  background-position: center 80px;
}

.min .nav li.ok a.v1 {
  background-position: center 40px;
}

.nav .sub {
  display: none;
  position: absolute;
  top: 100%;
  padding-left: 22px;
  z-index: 100
}

.nav .sub a {
  line-height: 70px;
  font-size: 14px;
  color: #fff;
  padding: 0 15px
}

.nav .sub a:hover {
  color: #757cbb
}

.so {
  float: right;
  width: 100px;
  height: 100%;
  position: relative;
  -webkit-transition: .3s;
  -o-transition: .3s;
  transition: .3s;
}

.so .so-btn {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  -o-transition: .3s;
  -ms-transition: .3s;
  -moz-transition: .3s;
  -webkit-transition: .3s;
  transition: .3s;
  background: url(../images/so_sub.png) center center no-repeat;
}

.so .so-btn:hover,
.so-on .so-btn {
  background: #757cbb url(../images/so_sub1.png) center center no-repeat;
}

.so .so-box {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  width: 240px;
  height: 40px;
  border: 2px solid #757cbb;
  background: #fff;
}

.so .inp {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0 45px 0 5px;
  -webkit-appearance: none;
}

.so .btn {
  position: absolute;
  right: 0;
  top: 0;
  width: 40px;
  height: 100%;
  background: url(../images/so.png) center no-repeat #8a8fc5;
  font-size: 0;
  cursor: pointer;
}

.header.min {
  height: 60px;
  background: rgba(255, 255, 255, 1);
}


/*.header.min .logo{max-width:80px}*/

.header.min .logo,
.header.min .nav li>a {
  line-height: 60px
}

.header.min .logo {
  display: none;
}

.header.min .logo1 {
  display: block;
  height: 60%;
}


/*.header.min .so{margin-top:21px}*/

.header:after {
  content: '';
  height: 0;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background-color: rgba(141, 197, 86, .8);
  z-index: 99;
  -webkit-transition: .3s;
  -o-transition: .3s;
  transition: .3s
}

.header.on:after {
  height: 70px
}

.menuBtn {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  transition: .3s;
  -ms-transition: .3s;
  -moz-transition: .3s;
  -webkit-transition: .3s;
  -o-transition: .3s
}

.menuBtn b {
  display: block;
  height: 4px;
  background-color: #757cbb;
  margin: 4px 0;
  transition: .3s;
  -ms-transition: .3s;
  -moz-transition: .3s;
  -webkit-transition: .3s;
  -o-transition: .3s
}

.menuBtn.open b {
  display: none;
  margin: -5px 0 0;
  position: absolute;
  left: 0;
  top: 50%;
  width: 30px
}

.menuBtn.open b:first-child {
  display: block;
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  -o-transform: rotate(45deg);
  -ms-transform: rotate(45deg)
}

.menuBtn.open b:last-child {
  display: block;
  transform: rotate(-45deg);
  -webkit-transform: rotate(-45deg);
  -o-transform: rotate(-45deg);
  -ms-transform: rotate(-45deg)
}

@media only screen and (max-width:959px) {
  .menuBtn {
    display: block
  }
  .header {
    height: 50px
  }
  .logo {
    display: none;
  }
  .logo1 {
    display: block;
    line-height: 50px;
    padding-left: 10px;
  }
  .logo1 img {
    height: 16px;
  }
  .header .wp {
    width: auto
  }
  .hdr {
    display: none;
    height: auto;
    background-color: rgba(255, 255, 255, .9);
    background-color: rgb(255, 255, 255)\9;
    float: none;
    position: absolute;
    top: 50px;
    left: 0;
    right: 0;
    box-shadow: 0 0 5px rgba(0, 0, 0, .5)
  }
  .so {
    float: none;
    padding: 10px 0;
    width: auto;
  }
  .so .so-btn {
    display: none;
  }
  .so .so-box {
    display: block;
    position: relative;
    margin: 0 auto;
  }
  .nav {
    float: none
  }
  .nav li {
    float: none;
    border-bottom: 1px solid #a0a0a0;
  }
  .nav li>a {
    line-height: 42px;
    padding: 0;
    margin: 0;
    text-align: center;
    width: auto;
  }
  .nav .sub a {
    color: #666;
    line-height: 32px;
    display: block;
    text-align: center
  }
  .nav .sub {
    position: static;
    padding: 0 0 10px
  }
}