user2653288 user2653288 - 7 months ago 17
HTML Question

responsive menu is not working in my website what I am Missing

Here is code

<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="css/style_inventive.css" rel="stylesheet" media="screen">


where style_inventive.css is style sheet I am using for menu

here is CSS file contents

@media (min-width: 768px){
.navbar-right .dropdown-menu {

right: auto;

}}

.nav>li>a:hover
{
background-color: #336699;
color:#fff;
}
.dropdown-menu
{
margin: 0px;
padding-top :0px;
padding-bottom: 0px;
color: #fff;
}
.dropdown-menu>li>a:hover
{
background-color: #336699;
color:#fff;
}

.dropdown-menu li
{
height: 40;
color: #fff;
float: none;
display: block;
margin: 0;
text-align: left;
border: 0;
border-bottom: 1px solid #d5d5d5;
}
.dropdown-menu a
{
margin-top: 10;
}


Here is HTML Code for menu

<div class="col-sm-7 menu">
<div class="collapse navbar-collapse">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<ul class="nav navbar-nav navbar-right">
<li><a href="home_inventive.html">HOME</a></li>
<li class="dropdown" id="licompany">
<a href="#" id="acompany" class="dropdown-toggle" data-toggle="dropdown">COMPANY </a>
<ul class="dropdown-menu" role="menu">
<li><a href="about_us.html">About Us</a></li>
<li><a href="team.html">Meet The Team</a></li>
<li><a href="join_us.html">Join Us</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">SERVICE </a>
<ul class="dropdown-menu" role="menu">
<li><a href="mobile_app_development.html">Mobile App Development</a></li>
<li><a href="software_development.html">Software Development</a></li>
<li><a href="web_development.html"> Web development</a></li>

</ul>
</li>
<li><a href="product.html">PORTFOLIO</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">TECHNOLOGY </a>
<ul class="dropdown-menu" role="menu">
<li><a href="php.html">PHP</a></li>
<li><a href="java.html">JAVA</a></li>
<li><a href="android.html">Android</a></li>
<li><a href="dotnet.html">.Net</a></li>
<li><a href="ios.html">iOS</a></li>
</ul>
</li>
<li><a href="sitemap.html">SITEMAP</a></li>
</ul>
</div>
</div>


Except menu everything is shown when I resize my browser...
menu is not shown when I resize

Answer

I just updated html structure according to bootstrap example its working.

  1. if you see bootstrap example thay used navbar-header outside the collapse navbar-collapse but in your case you missed it.
  2. second you'r targeting navbar-responsive-collapse in data-target=".navbar-responsive-collapse" but you have not define it in with navbar-collapse so i just add example targeted ID data-target="#bs-example-navbar-collapse-1" and define it in <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">.
  3. I just take another element navbar navbar-default inside col-sm-7 menu this is important thing that you have missed without the navbar class its obviously will not work.

see fiddle

<div class="col-sm-7 menu">
  <nav class="navbar navbar-default">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Brand</a>
    </div>
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="home_inventive.html">HOME</a></li>
        <li class="dropdown" id="licompany">
          <a href="#" id="acompany" class="dropdown-toggle" data-toggle="dropdown">COMPANY </a>
          <ul class="dropdown-menu" role="menu">
            <li><a href="about_us.html">About Us</a></li>
            <li><a href="team.html">Meet The Team</a></li>
            <li><a href="join_us.html">Join Us</a></li>
          </ul>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">SERVICE </a>
          <ul class="dropdown-menu" role="menu">
            <li><a href="mobile_app_development.html">Mobile App Development</a></li>
            <li><a href="software_development.html">Software Development</a></li>
            <li><a href="web_development.html"> Web development</a></li>

          </ul>
        </li>
        <li><a href="product.html">PORTFOLIO</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">TECHNOLOGY </a>
          <ul class="dropdown-menu" role="menu">
            <li><a href="php.html">PHP</a></li>
            <li><a href="java.html">JAVA</a></li>
            <li><a href="android.html">Android</a></li>
            <li><a href="dotnet.html">.Net</a></li>
            <li><a href="ios.html">iOS</a></li>
          </ul>
        </li>
        <li><a href="sitemap.html">SITEMAP</a></li>
      </ul>
    </div>
  </nav>

</div>
Comments