adc

clicks

navigation bar with search box using html & css

 navigation bar with search box using html & css

 navigation bar is a user interface component inside a webpage that holds links to other parts of the website. A website navigation bar is most usually displayed as a straight list of links at the top of per page.
Today in this blog, I'll deal with you this record (Responsive Navbar with Search Box). This navbar is fully responsive to any device. On mobile methods, this navbar will alter their height-width automatically according to the device height-width. I used CSS Flex and @media homey to make this Navbar Fully Responsive. The search box of this navbar is to create only for design trusts so, when you recorded any info in the research bar and click to the search key, it won't show you any results.

 

HTML

Before we start writing code first, we need to create a primary structure of the HTML document, so that the browser can understand and start working. The basic HTML structure looks like the following.

After writing the primary structure of the HTML document, you will also write the tags and content you need. After that, you can see the output in your browser. We know that HTML Sudu Mae is used for exposing content in a basic format. To complete our content we need to use CSS, which is an HTML insert and it creates an engaging user interface.

 <!DOCTYPE html>
<html>
<head>
    <title>navigration bar and search-box</title>
    <link rel="stylesheet" type="text/css" href="style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <script>
        
        $(document).ready(function() {
     
            $(".fa-search").click(function() {
               $(".search-box").toggle();
               $("input[type='text']").focus();
             });
 
         });

    </script>
</head>
<body>
    <div class="wrapper">
        <ul>
            <li>Home</li>
            <li class="mob">contact</li>
            <li class="mob">About</li>
            <li class="mob">Maps</li>

            <li class="active">
                <i class="fa fa-search" aria-hidden="true"></i>
                <div class="search-box">
                    <input type="text" name="" placeholder="">
                    <input type="button" name="" value="button">
                </div>
            </li>
        </ul>
    </div>
</body>
</html>

CSS

Now, we have time to improve the HTML content, for that, we need to add CSS to the HTML file. CSS can be added to HTML documents in a total of three ways, here we are using outside CSS design using CSS will arrive here after typing and see the output in your browser.

*{
  margin: 0;
  padding: 0;
}

body{
  user-select: none;
  background: #cae6f6;
}

.wrapper{
  width: 100%;
  height: 50px;
  background: #515052;
}

ul{
  list-style: none;
  width: 860px;
  margin: 0 auto;
}

ul li{
  color: #fff;
  float: left;
  width: 133px;
  line-height: 50px;
  text-align: center;
  cursor: pointer;
  font-weight: 900;
  text-transform: uppercase;
  font-family: Arial;
  transition: 0.5s;
  position: relative;
}

ul li:nth-child(3){
  background: #0d47a1;
}

ul li:hover:not(.active){
  background: #0d47a1;
}

.search-box{
  background: #E8E8E4;
  position: absolute;
  top: 54px;
  right: 28.7%;
  width: 350px;
  height: 60px;
  line-height: 60px;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  border-top:4px solid #0d47a1;
  display: none;
}

.search-box:before{
  content: "";
  position: absolute;
  top: -32px;
  right: 13px;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 14px solid transparent;
  border-bottom: 14px solid #0d47a1;
}

.search-box input[type="text"]{
  width: 200px;
  padding: 5px 10px;
  margin-left: 23px;
  border: 1px solid #0d47a1;
  outline: none;
}

.search-box input[type="button"]{
  width: 80px;
  padding: 5px 0;
  background: #0d47a1;
  color: #fff;
  margin-left: -6px;
  border: 1px solid #0d47a1;
  outline: none;
  cursor: pointer;
}

@media screen and(max-width: 700px){
    ul{
        width: 200px;
    }
    ul li{
        width: 100px;
    }
    ul li.active{
        text-align: right;
    }
    ul li.mob{
        display: none;
    }
    .search-box{
        width: 270px;
        right: -16%;
    }
    .search-box input[type="text"]{
        width: 140px;
        margin-left: 15px;
    }

    .search-box[type="button"]{
        margin-right: 12px;
    }

}


 Youtube Video Tutorials

 

 
 
 
 
 
 

navigation bar with search box using html & css navigation bar with search box using html & css Reviewed by easycoding on August 10, 2020 Rating: 5

No comments:

Powered by Blogger.