user6140292 user6140292 - 2 months ago 6x
CSS Question

How to make up responsive menu bar side by side with search bar on Blogger

I have a blog and I want to set the menu bar side by side with search bar.

I successfully coded it and it display very well in desktop or mobile. The problem is when I click to the menu icon (appear in mobile or smaller screen) the search bar goes down. I can't make the search bar stick to its position.

To better understand my problem take a look at the picture link below.

this is desktop view - OK

this is responsive view - OK

this is responsive view when i click on menu icon - not OK, the search bar should always in top

this is the code

<!DOCTYPE html>
body {margin:0;}
ul.main-menu {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #193550;


ul.main-menu li {float: left;}

ul.main-menu li a {
display: inline-block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
transition: 0.3s;
font-size: 16px;

ul.main-menu li a:hover {background-color: #111;}

ul.main-menu li.icon {display: none;}

@media screen and (max-width:680px) {
ul.main-menu li:not(:first-child) {display:

ul.main-menu li.icon {
float: left;
display: inline-block;

@media screen and (max-width:680px) {
ul.main-menu.responsive-main-menu {position:

ul.main-menu.responsive-main-menu li.icon {
position: relative;
right: 0;
top: 0;
ul.main-menu.responsive-main-menu li {
float: none;
display: inline;
ul.main-menu.responsive-main-menu li a {
display: block;
text-align: left;
#searchbar{float:right; margin:7px 8px 5px 0;}
#searchbar input[type="text"] { -moz-box-sizing:

border-box;background: #FCFCFC; border: 1px solid

#DFDFDF; box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);

color: #888888; padding: 5px 0; width: 120px;

transition: all 0.25s linear 0s; text-indent:8px;}
#searchbar button {background:#00a1e0; border:0;

color: #FFFFFF; cursor:pointer; padding:5px 8px;

box-shadow:0 0 0 3px rgba(0, 0, 0, 0.04);}
#searchbar button:hover{opacity:0.8;}
<ul class="main-menu">
<li class="icon">
<a href="javascript:void(0);" style="font-

size:15px;" onclick="myFunction()">☰ MENU</a>
<li><a class="active" href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
<form action='/search' id='searchbar' method='get'>
<input id='s' name='q' onblur='if (this.value ==

&quot;&quot;) {this.value = &quot;Enter

keywords&quot;;}' onfocus='if (this.value ==

&quot;Enter keywords&quot;) {this.value =

&quot;&quot;;}' type='text' value='Enter

<button type='submit'><i class='fa fa-


function myFunction() {



    <div id="top">

    <div class="nav">
    <ul class="main-menu">

    <div class="search">  


CSS Code

.nav {

.search {
    float: right;