Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap Navbar Brand image gets pushed down upon collapse

My navbar brand image gets pushed down when I resize my screen to simulate mobile. How can I use media queries to resize the navbar-header (since I think it's the one that doesn't resize and forces the brand image to go down)?

   <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"style="margin-top:27px;">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" style="">
           <%=image_tag "elem_logo-white.png", :style => "width: 95%;"%> 
          </a>
   </div>

enter image description here enter image description here

I did this line of code however it did not work. The image became smaller, however the navbar still fragmented. @media (max-width:768px){ .navbar-brand img{ width:100px!important; } }

enter image description here

like image 357
Acrux Avatar asked Nov 22 '25 17:11

Acrux


2 Answers

You have to give it smaller width on small screens like

@media (max-width:768px){
 .navbar-brand img{
   width:100px;
   max-height:50px;
 }
}
like image 95
Peter Wilson Avatar answered Nov 25 '25 08:11

Peter Wilson


I solved it by editing Peter Wilson's suggestion. Here's what worked:

    @media (max-width:768px){
        .navbar-brand{
       width:70vw!important;
      }
    }
like image 40
Acrux Avatar answered Nov 25 '25 08:11

Acrux



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!