将汉堡菜单和搜索框添加到导航菜单

时间:2017-06-20 17:05:17

标签: javascript jquery css navigationbar hamburger-menu

我正在尝试将汉堡菜单和搜索框添加到我的主标题菜单中。我已经完成了所有工作,但是我无法在主标题中对齐。搜索功能也没有出现,即使它在另一个jsfiddle(https://jsfiddle.net/o9vdhv9u/)中工作得很好。我想在左边有一个汉堡菜单,在导航链接的右边有一个搜索功能(例如下面的例子)。有没有人有任何解决方案?

我试图让它看起来像...的例子 enter image description here

jsfiddle - https://jsfiddle.net/ubfwqdkt/

搜索功能的jsfiddle - https://jsfiddle.net/o9vdhv9u/



jQuery(document).ready(function() {
  jQuery('#hamburger-nav-icon').click(function() {
    jQuery(this).toggleClass('open');
    if (jQuery('#hamburger-menu').css('opacity') == '0') {
      jQuery('#hamburger-menu').css('opacity', '1');
      jQuery('#hamburger-menu').fadeIn(300).css('display', 'table');
    } else {
      jQuery('#hamburger-menu').css('opacity', '0');
      jQuery('#hamburger-menu').fadeOut(300).css('display', 'none');
    }
  });
});
document.getElementById("search-label").addEventListener("click", function(e) {
  if (e.target == this) {
    e.preventDefault();
    this.classList.toggle("clicked");
  }
});

/*--------------------------------------------------------------
## Header
--------------------------------------------------------------*/

#ht-masthead{
background-color: #fff;
  height: 70px;
  border-bottom: 1px solid #eee;
  z-index: 99;
  transition: height 0.3s ease;
  -moz-transition: height 0.3s ease;
  -webkit-transition: height 0.3s ease;
  position: fixed;
  text-align: center;
  width: 0 auto;
  margin-right: 38px;
  width: 100%;
}
.ht-site-title{
font-family: 'futura_tbold';
    font-size: 24px;
    text-transform: uppercase;
letter-spacing: 6px;
        line-height: 1;
    margin-bottom: 8px;
    margin-top:5px;
    margin-left: 75px;
    text-align: left;
    float: left;

    padding: 15px 0;
transition: padding 0.3s ease;
-moz-transition: padding 0.3s ease;
-webkit-transition: padding 0.3s ease;
    width:20%;
}

.ht-site-title a{
text-decoration: none;
color: #000;
}
.ht-site-title a:hover{
text-decoration: none;
color: #000;
}
.ht-site-description{
color: #EEE;
margin: 0;
font-size: 15px;
font-style: italic;
line-height: 1;
}

.ht-site-description a{
color: #333;
}
/*--------------------------------------------------------------
## General
--------------------------------------------------------------*/
#ht-content {
    padding-top: 200px;
}
.ht-section {
  padding: 60px 0;
  background: #FFF;
}

.ht-section-title-tagline {
  margin-bottom: 60px;
  text-align: center;
}

.ht-section-title {
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 36px;
  width: 60%;
  margin: 0 auto 15px;
}

.ht-section-title:last-child {
  margin-bottom: 0;
}

.ht-section-tagline {
  font-size: 20px;
  width: 70%;
  margin: 0 auto;
}

#ht-page {
  width: 100% !important;
  margin: 0 auto;
  max-width: 100% !important;
  overflow: hidden !important;
}


/*--------------------------------------------------------------
## Menus
--------------------------------------------------------------*/

#ht-site-navigation {
float: right;
width: 70%;
margin-top: -52px;
    margin-right:200px;
transition: padding 0.3s ease;
-moz-transition: padding 0.3s ease;
-webkit-transition: padding 0.3s ease;
}

.ht-sticky #ht-site-navigation {
  padding: 17px 0;
}

.ht-main-navigation .ht-menu {}

.ht-main-navigation ul {
  list-style: none;
  margin: 0;
  padding-left: 0;
  display: inline-block;
  position: relative;
}

.ht-main-navigation li {
  float: left;
  margin-left: 30px;
}

.ht-main-navigation a {
  display: block;
  text-decoration: none;
  color: #000;
  text-transform: uppercase;
  font-size: 15px;
  font-family: 'Raleway', sans-serif;
  line-height: 36px;
  padding: 0 15px;
  font-weight: 600;
  letter-spacing: 2px;
  padding-bottom: 40px;
}

.ht-main-navigation ul ul {
  position: absolute;
  left: 0;
  top: 100%;
  background: #FFF;
  min-width: 200px;
 right:0;
  z-index: 999;
  padding: 8px;
  margin-top: -21px;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.05);
    height:300px;
    transform: scaleY(0);
    -webkit-transform-origin: top;
    -moz-transform-origin: top;
    transform-origin: top;
    -webkit-transition: all .3s ease-in-out;
    -moz-transition: all .3s ease-in-out;
    opacity: 0;
}

.ht-sticky .ht-main-navigation ul ul {
  margin-top: 17px;
}

.ht-main-navigation ul ul ul {
  left: 100%;
  top: 0;
  margin: 0 0 0 8px;
  border-top: 0;
}

.ht-sticky .ht-main-navigation ul ul ul {
  margin-top: 0;
}

.ht-main-navigation ul ul a {
  text-transform: uppercase;
  font-weight: 400;
  color: #444;
  line-height: 1.5;
  padding: 7px 25px;
  font-size: 12px;
 text-align: left;
}
.ht-main-navigation ul ul li:first-child {
    padding-top: 15px;
}
.ht-main-navigation ul ul li {
  float: none;
  margin: 0 0 5px;
}

.ht-main-navigation ul ul li:last-child {
  margin-bottom: 0;
}

.ht-main-navigation ul li:hover > ul {
  opacity: 1;
  transform: scaleY(1);
}
.page-template-home-template .ht-main-navigation .current_page_item > a,
.page-template-home-template .ht-main-navigation .current-menu-item > a,
.page-template-home-template .ht-main-navigation .current_page_ancestor > a,
.home.blog .ht-main-navigation .current_page_item > a,
.home.blog .ht-main-navigation .current-menu-item > a,
.home.blog .ht-main-navigation .current_page_ancestor > a {
  background: none;
  color: inherit;
}

.ht-main-navigation li:hover > a,
.page-template-home-template .ht-main-navigation li:hover > a,
.home.blog .ht-main-navigation li:hover > a,
.ht-main-navigation .current_page_item > a,
.ht-main-navigation .current-menu-item > a,
.ht-main-navigation .current_page_ancestor > a,
.page-template-home-template .ht-main-navigation .current > a,
.home.blog .ht-main-navigation .current > a {
  color: #000;
  text-decoration: none;
}

.site-main .comment-navigation,
.site-main .posts-navigation,
.site-main .post-navigation {
  margin: 0 0 15px;
  overflow: hidden;
}

.comment-navigation .nav-previous,
.posts-navigation .nav-previous,
.post-navigation .nav-previous {
  float: left;
  width: 50%;
}

.comment-navigation .nav-next,
.posts-navigation .nav-next,
.post-navigation .nav-next {
  float: right;
  text-align: right;
  width: 50%;
}
.owl-item img{
    height: 256px;
    width:256px !important;
}
/*--------------------------------------------------------------
## Hamburger Menu
--------------------------------------------------------------*/
#hamburger-menu{
    z-index: 5;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0, 0.95);
    position: fixed;
    font-size: 1.5em;
    text-align: center;
    right: 0px;
    top: 0px;
    opacity: 0;
    display: table;
}

.hidden{
    display: none;
    visibility: none;
}

#hamburger-menu ul{
    margin: 0;
    padding: 0;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: table-cell;
    vertical-align: middle;
}

#hamburger-menu ul li{
    cursor: pointer;
    text-decoration: none;
}

#hamburger-menu ul li:hover{
    background-color: #006973;
    -webkit-transition: .15s ease-in-out;
    -moz-transition: .15s ease-in-out;
    -o-transition: .15s ease-in-out;
    transition: .15s ease-in-out;
}

#hamburger-menu ul a{
    letter-spacing: 5px;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    color: #fff;
    list-style: none;
    text-transform: uppercase;
    padding: 0px;
    line-height: 75px;
    padding: 10px 700px;
    text-decoration: none;
}

#hamburger-menu ul a:hover{
    text-decoration: none;
    color: #fff ;
}

#hamburger-nav-icon {
    z-index: 20;
  width: 50px;
  height: 35px;
  position: relative;
  margin: 35px 30px;
  -webkit-transform: rotate(0deg);
  -moz-transform: rotate(0deg);
  -o-transform: rotate(0deg);
  transform: rotate(0deg);
  -webkit-transition: .5s ease-in-out;
  -moz-transition: .5s ease-in-out;
  -o-transition: .5s ease-in-out;
  transition: .5s ease-in-out;
  cursor: pointer;
}

#hamburger-nav-icon span {
  display: block;
  position: absolute;
  height: 5px;
  width: 40px;
  background: #bada33;
  opacity: 1;
  left: 0;
  -webkit-transform: rotate(0deg);
  -moz-transform: rotate(0deg);
  -o-transform: rotate(0deg);
  transform: rotate(0deg);
  -webkit-transition: .25s ease-in-out;
  -moz-transition: .25s ease-in-out;
  -o-transition: .25s ease-in-out;
  transition: .25s ease-in-out;
}

/* Icon 3 */

#hamburger-nav-icon span:nth-child(1) {
  top: 0px;
}

#hamburger-nav-icon span:nth-child(2),#hamburger-nav-icon span:nth-child(3) {
  top: 12px;
}

#hamburger-nav-icon span:nth-child(4) {
  top: 24px;
}

#hamburger-nav-icon.open span:nth-child(1) {
  top: 8px;
  width: 0%;
  left: 50%;
}

#hamburger-nav-icon.open span:nth-child(2) {
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
  -o-transform: rotate(45deg);
  transform: rotate(45deg);
}

#hamburger-nav-icon.open span:nth-child(3) {
  -webkit-transform: rotate(-45deg);
  -moz-transform: rotate(-45deg);
  -o-transform: rotate(-45deg);
  transform: rotate(-45deg);
}

#hamburger-nav-icon.open span:nth-child(4) {
  top: 8px;
  width: 0%;
  left: 50%;
}
/*--------------------------------------------------------------
## Search
--------------------------------------------------------------*/
#ht-masthead .search-field {
  background-color: transparent;
  background-image: url(images/search-icon.png);
  background-position: 5px center;
  background-repeat: no-repeat;
  background-size: 24px 24px;
  border: none;
  cursor: pointer;
  height: 37px;
  margin: 3px 0;
  padding: 0 0 0 34px;
  position: relative;
  -webkit-transition: width 400ms ease, background 400ms ease;
  transition: width 400ms ease, background 400ms ease;
  width: 230px;
}

#ht-masthead .search-field:focus {
  background-color: #fff;
  border: 2px solid #c3c0ab;
  cursor: text;
  outline: 0;
}
#ht-masthead .search-form {
  display: none;
  position: absolute;
  right: 200px;
  top: 200px;
}
.search-toggle:hover #ht-masthead .search-form {
  display: block;
}
.search-form
    .search-submit {
  display: none;
}

.search-form {
  position: relative;
}

.search-form label {
  position: relative;
  background: url('https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-ios7-search-strong-128.png') 0 0 no-repeat;
  background-size: cover;
  width: 50px; height: 50px;
  text-indent: 9999px;
  overflow: hidden;
  white-space: nowrap;
}

.search-input {
  transform: translateY(-100%);
  opacity: 0;
  position: absolute;
  top: 100%;
  transition: opacity .25s, transform .25s;
  left: 0;
  z-index: -1;
  border: 0;
  outline: 0;
  
}
.search-label, .search-input {
  background: #ccc;
  padding: .5em;
  display: inline-block;
}

.clicked + .search-input {
  opacity: 1;
  transform: translateY(0);
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<header id="ht-masthead" class="ht-site-header">
<div class="ht-container ht-clearfix">
<div id="ht-site-branding">
    <div id="hamburger-nav-icon">
              <span></span>
              <span></span>
              <span></span>
              <span></span>
            </div>

        <div id="hamburger-menu">
            <ul>
                <li><a href="#">Link1</a></li>
                <li><a href="#">Link2</a></li>
                <li><a href="#">Link3</a></li>
                <li><a href="#">Link4</a></li>
                <li><a href="#">Link5</a></li>
            </ul>
</div> 
<div class="search-field">
</div>
<form role="search" method="get" class="search-form" action="http://localhost:8888/wordpress/">
  <label for="search-input" id="search-label" class="search-label">
    Search for:   
    </label>
<input id="search-input" type="search" class="search-input" placeholder="Search …" value="" name="s" title="Search for:">
  <input type="submit" class="search-submit" value="Search">
</form> 
<h1 class="ht-site-title"><a href="http://localhost:8888/wordpress/" rel="home">Site Name</a></h1>
<p class="ht-site-description"><a href="http://localhost:8888/wordpress/" rel="home"></a></p> 
</div><!-- .site-branding -->
<nav id="ht-site-navigation" class="ht-main-navigation">
<div class="toggle-bar"><span></span></div>
<div class="ht-menu ht-clearfix"><ul id="menu-primary-menu-links" class="ht-clearfix"><li id="menu-item-129" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-129"><a href="http://localhost:8888/wordpress/">Item 1</a>
<ul class="sub-menu">
	<li id="menu-item-139" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-139"><a href="http://localhost:8888/wordpress/">Sub Item 1</a></li>
	<li id="menu-item-140" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-140"><a href="http://localhost:8888/wordpress/">Sub Item 2</a></li>
	<li id="menu-item-138" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-138"><a href="http://localhost:8888/wordpress/">Sub Item 3</a></li>
	<li id="menu-item-137" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-137"><a href="http://localhost:8888/wordpress/">Sub Item 4</a></li>
</ul>
</li>
<li id="menu-item-128" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-128"><a href="http://localhost:8888/">Item 2</a>
<ul class="sub-menu">
	<li id="menu-item-142" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-142"><a href="http://localhost:8888/wordpress/">Sub Item 1</a></li>
	<li id="menu-item-143" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-143"><a href="http://localhost:8888/wordpress/">Sub Item 2</a></li>
	<li id="menu-item-141" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-141"><a href="http://localhost:8888/wordpress/">Sub Item 3</a></li>
</ul>
</li>
<li id="menu-item-132" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-132"><a href="http://localhost:8888/wordpress/">Item 3</a></li>
<li id="menu-item-130" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-130"><a href="http://localhost:8888/wordpress/">Item 4</a></li>
<li id="menu-item-759" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-759"><a href="http://localhost:8888/wordpress/">Item 5</a></li>
<li id="menu-item-135" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-135"><a href="http://localhost:8888/wordpress/">Item 6</a></li>
<li id="menu-item-133" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-133"><a href="http://localhost:8888/wordpress/">Item 7</a>
<ul class="sub-menu">
	<li id="menu-item-150" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-150"><a href="http://localhost:8888/wordpress/">Sub Item 1</a></li>
	<li id="menu-item-149" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-149"><a href="http://localhost:8888/wordpress/">Sub Item 2</a></li>
	<li id="menu-item-148" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-148"><a href="http://localhost:8888/wordpress/">Sub Item 3</a></li>
	<li id="menu-item-147" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-147"><a href="http://localhost:8888/wordpress/">Sub Item 4</a></li>
</ul>
</li>
<li id="menu-item-509" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-509"><a href="http://localhost:8888/wordpress/">Item 8</a>
<ul class="sub-menu">
	<li id="menu-item-512" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-512"><a href="http://localhost:8888/wordpress/">Sub Item 1</a></li>
	<li id="menu-item-510" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-510"><a href="http://localhost:8888/wordpress/">Sub Item 2</a></li>
	<li id="menu-item-513" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-513"><a href="http://localhost:8888/wordpress/">Sub Item 3</a></li>
	<li id="menu-item-511" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-511"><a href="http://localhost:8888/wordpress/">Sub Item 4</a></li>
</ul>
</li>
</ul></div></nav><!-- #ht-site-navigation -->
</div>
</header>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

需要更多的工作来处理子菜单和汉堡菜单的布局,但我认为这是一个好的开始

Fiddle

jQuery(document).ready(function() {
  jQuery('#hamburger-nav-icon').click(function() {
    jQuery(this).toggleClass('open');
    if (jQuery('#hamburger-menu').css('opacity') == '0') {
      jQuery('#hamburger-menu').css('opacity', '1');
      jQuery('#hamburger-menu').fadeIn(300).css('display', 'table');
    } else {
      jQuery('#hamburger-menu').css('opacity', '0');
      jQuery('#hamburger-menu').fadeOut(300).css('display', 'none');
    }
  });
});
document.getElementById("search-label").addEventListener("click", function(e) {
  if (e.target == this) {
    e.preventDefault();
    this.classList.toggle("clicked");
  }
});
/*--------------------------------------------------------------
## Header
--------------------------------------------------------------*/

#ht-masthead {
  background-color: #fff;
  height: 70px;
  border-bottom: 1px solid #eee;
  transition: height 0.3s ease;
  position: fixed;
  display: flex;
  justify-content: space-between;
}

#ht-site-branding {
  display: flex;
  align-items: center;
}

.ht-site-title {
  font-family: 'futura_tbold';
  font-size: 24px;
  text-transform: uppercase;
  margin-left: 1em;
  display: inline-block;
}

.ht-site-title a {
  text-decoration: none;
  color: #000;
}

.ht-site-description {
  color: #EEE;
  font-size: 15px;
  font-style: italic;
}

.ht-site-description a {
  color: #333;
}


/*--------------------------------------------------------------
## General
--------------------------------------------------------------*/

#ht-content {
  padding-top: 200px;
}

.ht-section {
  padding: 60px 0;
  background: #FFF;
}

.ht-section-title-tagline {
  margin-bottom: 60px;
  text-align: center;
}

.ht-section-title {
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 36px;
  width: 60%;
  margin: 0 auto 15px;
}

.ht-section-title:last-child {
  margin-bottom: 0;
}

.ht-section-tagline {
  font-size: 20px;
  width: 70%;
  margin: 0 auto;
}


/*--------------------------------------------------------------
## Menus
--------------------------------------------------------------*/

#ht-site-navigation {
  display: flex;
}

.ht-main-navigation .ht-menu {}

.ht-main-navigation ul {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
}

.ht-main-navigation li {
  list-style: none;
  padding: 1em 0.5em;
  position: relative;
}

.ht-main-navigation ul li:hover ul.sub-menu {
  display: flex;
}

.ht-main-navigation a {
  color: black;
  display: inline-block;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 0.9em;
  font-family: 'Raleway', sans-serif;
}

.ht-main-navigation ul.sub-menu {
  position: absolute;
  left: -48px;
  top: 30px;
  display: none;
  flex-flow: column;
  flex-wrap: nowrap;
  min-width: 6em;
}

.ht-main-navigation ul ul ul {}

.ht-main-navigation ul ul a {
  text-transform: uppercase;
  color: #444;
  font-size: 12px;
}

.ht-main-navigation ul ul li:first-child {}

.ht-main-navigation ul ul li {}

.ht-main-navigation ul ul li:last-child {}

.ht-main-navigation ul li:hover > ul {}

.page-template-home-template .ht-main-navigation .current_page_item > a,
.page-template-home-template .ht-main-navigation .current-menu-item > a,
.page-template-home-template .ht-main-navigation .current_page_ancestor > a,
.home.blog .ht-main-navigation .current_page_item > a,
.home.blog .ht-main-navigation .current-menu-item > a,
.home.blog .ht-main-navigation .current_page_ancestor > a {
  background: none;
  color: inherit;
}

.ht-main-navigation li:hover > a,
.page-template-home-template .ht-main-navigation li:hover > a,
.home.blog .ht-main-navigation li:hover > a,
.ht-main-navigation .current_page_item > a,
.ht-main-navigation .current-menu-item > a,
.ht-main-navigation .current_page_ancestor > a,
.page-template-home-template .ht-main-navigation .current > a,
.home.blog .ht-main-navigation .current > a {
  color: #000;
  text-decoration: none;
}

.site-main .comment-navigation,
.site-main .posts-navigation,
.site-main .post-navigation {
  margin: 0 0 15px;
  overflow: hidden;
}

.comment-navigation .nav-previous,
.posts-navigation .nav-previous,
.post-navigation .nav-previous {
  width: 50%;
}


/*--------------------------------------------------------------
## Hamburger Menu
--------------------------------------------------------------*/

#hamburger-menu {
  background-color: rgba(0, 0, 0, 0.95);
  font-size: 1.5em;
  opacity: 0;
  display: none;
}

#hamburger-menu ul {
  margin: 0;
  padding: 0;
}

#hamburger-menu ul li {
  cursor: pointer;
}

#hamburger-menu ul li:hover {
  background-color: #006973;
}

#hamburger-menu ul a {
  color: #fff;
  text-transform: uppercase;
  text-decoration: none;
}

#hamburger-menu ul a:hover {}

#hamburger-nav-icon {
  cursor: pointer;
  position: relative;
  display: inline-block;
  width: 40px;
  height: 30px;
}

#hamburger-nav-icon span {
  display: block;
  position: absolute;
  height: 5px;
  width: 40px;
  background: #bada33;
  left: 0;
}


/* Icon 3 */

#hamburger-nav-icon span:nth-child(1) {
  top: 0px;
}

#hamburger-nav-icon span:nth-child(2),
#hamburger-nav-icon span:nth-child(3) {
  top: 12px;
}

#hamburger-nav-icon span:nth-child(4) {
  top: 24px;
}

#hamburger-nav-icon.open span:nth-child(1) {
  top: 8px;
  width: 0%;
  left: 50%;
}

#hamburger-nav-icon.open span:nth-child(2) {
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
  -o-transform: rotate(45deg);
  transform: rotate(45deg);
}

#hamburger-nav-icon.open span:nth-child(3) {
  -webkit-transform: rotate(-45deg);
  -moz-transform: rotate(-45deg);
  -o-transform: rotate(-45deg);
  transform: rotate(-45deg);
}

#hamburger-nav-icon.open span:nth-child(4) {
  top: 8px;
  width: 0%;
  left: 50%;
}


/*--------------------------------------------------------------
## Search
--------------------------------------------------------------*/

#ht-masthead .search-field {
  padding: 0 10px 0 34px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

#ht-masthead .search-field:focus {
  background-color: #fff;
  border: 2px solid #c3c0ab;
  cursor: text;
  outline: 0;
}

#ht-masthead .search-form {}

.search-toggle:hover #ht-masthead .search-form {
  display: block;
}

.search-form .search-submit {
  display: none;
}

.search-form {
  position: relative;
}

.search-form label {
  position: relative;
  background: url('https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-ios7-search-strong-128.png') 0 0 no-repeat;
  background-size: cover;
}

.search-input {
  transform: translateY(-100%);
  opacity: 0;
  position: absolute;
  top: 100%;
  transition: opacity .25s, transform .25s;
  left: 0;
  z-index: -1;
  border: 0;
  outline: 0;
}

.search-label,
.search-input {
  background: #ccc;
  padding: .5em;
  display: inline-block;
}

.clicked + .search-input {
  opacity: 1;
  transform: translateY(0);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<header id="ht-masthead" class="ht-site-header">
  <div id="ht-site-branding">
    <div id="hamburger-nav-icon">
      <span></span>
      <span></span>
      <span></span>
      <span></span>
    </div>

    <div id="hamburger-menu">
      <ul>
        <li><a href="#">Link1</a></li>
        <li><a href="#">Link2</a></li>
        <li><a href="#">Link3</a></li>
        <li><a href="#">Link4</a></li>
        <li><a href="#">Link5</a></li>
      </ul>
    </div>
    <h1 class="ht-site-title"><a href="http://localhost:8888/wordpress/" rel="home">Site Name</a></h1>
    <p class="ht-site-description">
      <a href="http://localhost:8888/wordpress/" rel="home"></a>
    </p>

  </div>
  <!-- .site-branding -->
  <nav id="ht-site-navigation" class="ht-main-navigation">
    <ul id="menu-primary-menu-links" class="ht-clearfix">
      <li id="menu-item-129" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-129"><a href="http://localhost:8888/wordpress/">Item 1</a>
        <ul class="sub-menu">
          <li id="menu-item-139" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-139"><a href="http://localhost:8888/wordpress/">Sub Item 1</a></li>
          <li id="menu-item-140" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-140"><a href="http://localhost:8888/wordpress/">Sub Item 2</a></li>
          <li id="menu-item-138" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-138"><a href="http://localhost:8888/wordpress/">Sub Item 3</a></li>
          <li id="menu-item-137" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-137"><a href="http://localhost:8888/wordpress/">Sub Item 4</a></li>
        </ul>
      </li>
      <li id="menu-item-128" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-128"><a href="http://localhost:8888/">Item 2</a>
        <ul class="sub-menu">
          <li id="menu-item-142" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-142"><a href="http://localhost:8888/wordpress/">Sub Item 1</a></li>
          <li id="menu-item-143" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-143"><a href="http://localhost:8888/wordpress/">Sub Item 2</a></li>
          <li id="menu-item-141" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-141"><a href="http://localhost:8888/wordpress/">Sub Item 3</a></li>
        </ul>
      </li>
      <li id="menu-item-132" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-132"><a href="http://localhost:8888/wordpress/">Item 3</a></li>
      <li id="menu-item-130" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-130"><a href="http://localhost:8888/wordpress/">Item 4</a></li>
      <li id="menu-item-759" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-759"><a href="http://localhost:8888/wordpress/">Item 5</a></li>
      <li id="menu-item-135" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-135"><a href="http://localhost:8888/wordpress/">Item 6</a></li>
      <li id="menu-item-133" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-133"><a href="http://localhost:8888/wordpress/">Item 7</a>
        <ul class="sub-menu">
          <li id="menu-item-150" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-150"><a href="http://localhost:8888/wordpress/">Sub Item 1</a></li>
          <li id="menu-item-149" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-149"><a href="http://localhost:8888/wordpress/">Sub Item 2</a></li>
          <li id="menu-item-148" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-148"><a href="http://localhost:8888/wordpress/">Sub Item 3</a></li>
          <li id="menu-item-147" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-147"><a href="http://localhost:8888/wordpress/">Sub Item 4</a></li>
        </ul>
      </li>
      <li id="menu-item-509" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-509"><a href="http://localhost:8888/wordpress/">Item 8</a>
        <ul class="sub-menu">
          <li id="menu-item-512" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-512"><a href="http://localhost:8888/wordpress/">Sub Item 1</a></li>
          <li id="menu-item-510" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-510"><a href="http://localhost:8888/wordpress/">Sub Item 2</a></li>
          <li id="menu-item-513" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-513"><a href="http://localhost:8888/wordpress/">Sub Item 3</a></li>
          <li id="menu-item-511" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-511"><a href="http://localhost:8888/wordpress/">Sub Item 4</a></li>
        </ul>
      </li>
    </ul>
  </nav>
  <!-- #ht-site-navigation -->
  <div class="search-field">
    <form role="search" method="get" class="search-form" action="http://localhost:8888/wordpress/">
      <label for="search-input" id="search-label" class="search-label"></label>
      <input id="search-input" type="search" class="search-input" placeholder="Search …" value="" name="s" title="Search for:">
      <input type="submit" class="search-submit" value="Search">
    </form>
  </div>
</header>