Solution 1 :

use media queries to control the bootstrap Responsive breakpoints

.navbar {
  background-color: #951010;
  padding-top: 1em;
  padding-bottom: 1em;
}

.navbar-brand {
  color: #FFF;
  font-size: 2em;
}

.navbar-default .navbar-nav>li>a {
  color: #FFF;
}

@media (min-width: 100px) and (max-width: 400px) {
  .navbar-brand {
    font-size: 1em;
  }
}
<!DOCTYPE html>
<html>

<head>
  <title>Footer Pen</title>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css">
  <link rel="stylesheet" href="/stylesheets/main.css">
  <script src="https://kit.fontawesome.com/175e0bfa97.js" crossorigin="anonymous"></script>
</head>

<body>
  <nav class="navbar navbar-expand-md navbar-dark fixed-top shadow mb-3">
    <a class="navbar-brand" href="/"><i class="fas fa-dna"></i> cyclone <strong>analytics</strong></a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
    <div class="collapse navbar-collapse" id="navbarCollapse">
      <ul class="navbar-nav mr-auto">
        <li class="nav-item active">
          <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Players</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Seasons</a>
        </li>
      </ul>
    </div>
  </nav>


  <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>

</html>

Solution 2 :

You need to add a media query that reduces the font-size of the ‘cyclone analytics’ on smaller devices. The reason the nav bar is getting bigger is because the hamburger is being wrapped onto a new line.

So if you add a media query along the lines of:

@media only screen and (max width: 700px) {

.navbar-brand: font-size: 1rem;

}

It’ll work because the main logo is smaller, so the hamburger isn’t being wrapped. Hope that helps. 🙂

Problem :

I have a web app that I’m working with where the Nav bar’s height doubles in size on a mobile view. Here’s what it typically looks like:

enter code here

And here’s what it looks like an a mobile view:

enter image description here

What can I do to prevent this resizing? Is there a way to make the header and logo responsive based on screen size? Here’s the code I’ve got:

.navbar {
    background-color: #951010;
    padding-top: 1em;
    padding-bottom: 1em;
}

.navbar-brand {
    color: #FFF;
    font-size: 2em;
}

.navbar-default .navbar-nav>li>a {
    color: #FFF;
}
<!DOCTYPE html>
<html>
    <head>
        <title>Footer Pen</title>
        <!-- Required meta tags -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <!-- Bootstrap CSS -->
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> 
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css">
        <link rel="stylesheet" href="/stylesheets/main.css">
        <script src="https://kit.fontawesome.com/175e0bfa97.js" crossorigin="anonymous"></script>
  </head>
<body>
     <nav class="navbar navbar-expand-md navbar-dark fixed-top shadow mb-3">
        <a class="navbar-brand" href="/"><i class="fas fa-dna"></i> cyclone <strong>analytics</strong></a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarCollapse">
            <ul class="navbar-nav mr-auto">
                <li class="nav-item active">
                    <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Players</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Seasons</a>
                </li>
            </ul>
       </div>
  </nav>


         <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
    </body>
</html>

What am I missing here?

Comments

Comment posted by ikiK

I can not replicate this “problem” even with your codepen, on 300px width… Seems all is ok…

Comment posted by Franchise

@ikiK – I have this deployed as a Heroku app and viewing the site on mobile presents the issue.

Comment posted by ikiK

Cant help with that, like i say I can not replicate the problem.

Comment posted by OmmiZone

(max-width: 400px)

Comment posted by Franchise

Thanks for this, media queries are what I needed!

Comment posted by Franchise

Thanks for this, it sent me in the right direction. Apart from a bit of formatting, this is what I was looking for.

By

Leave a Reply

Your email address will not be published. Required fields are marked *