Solution 1 :

I think I found the solution because the result is now pretty similar to the example.

I noticed that some style that was there in bootsrap v3.3.6 is no longer present in the corresponding classes.

I added the style directly inside HTML tags to separate it from the rest.

      body {
        font-size: 16px;
        color: #fff;
        background-color: #61122f;
        font-family: 'Oxygen', sans-serif;
      }

      /** HEADER **/
      #header-nav {
        background-color: #f6b319;
        border-radius: 0;
        border: 0;
      }

      #logo-img {
        background: url('https://www.shiva.com/Files/Directory%20Folders/19822_1.png') no-repeat;
        width: 170px;
        height: 150px;
        margin: 10px 15px 10px 0;
      }

      .navbar-brand {
        padding-top: 25px;
      }

      .navbar-brand h1 { /* Restaurant name */
        font-family: 'Lora', serif;
        color: #557c3e;
        font-size: 1.5em;
        text-transform: uppercase;
        font-weight: bold;
        text-shadow: 1px 1px 1px #222;
        margin-top: 0;
        margin-bottom: 0;
        line-height: .75;
      }
      .navbar-brand a:hover, .navbar-brand a:focus {
        text-decoration: none;
      }
      .navbar-brand p { /* Kosher cert */
        color: #000;
        text-transform: uppercase;
        font-size: .7em;
        margin-top: 15px;
      }
      .navbar-brand p span { /* Star-K */
        vertical-align: middle;
      }
    <!doctype html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>David Chu's China Bistro</title>
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
        <link href='https://fonts.googleapis.com/css?family=Oxygen:400,300,700' rel='stylesheet' type='text/css'>
        <link href='https://fonts.googleapis.com/css?family=Lora' rel='stylesheet' type='text/css'>
      </head>
    <body>
      <header>
        <nav id="header-nav" class=" navbar navbar-expand-sm navbar-light">
           <div class="container">
            <div>
              <a href="index.html" class="float-left d-none d-md-block d-lg-block">
                <div id="logo-img"></div>
              </a>
         
              <div class="navbar-brand" style="float: left; height:50px; white-space: normal;"> 
                <a href="index.html"><h1>David Chu's China Bistro</h1>
                </a>
               <p>
                 <img width="25" height="25" src="https://upload.wikimedia.org/wikipedia/en/thumb/1/19/Star-K_logo.jpg/340px-Star-K_logo.jpg" alt="Kosher certification" alt="Kosher certification"/>
              <span>Kosher Certified</span>
              </p>
              </div>

             <button style="position: relative; float: right;"class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
              <span class="navbar-toggler-icon"></span>
            </button>

          </div>
        </div>
      </nav>

    </header>


      <!-- jQuery (Bootstrap JS plugins depend on it) -->
      <script src="js/jquery-2.1.4.min.js"></script>
      <script src="js/bootstrap.min.js"></script>
      <script src="js/script.js"></script>
    </body>
    </html>

Problem :

I’m following an online course about HTML, CSS, and JavaScript where Bootstrap v3.3.6 is used.

I decided to follow the course using Bootstrap v4.5.0 instead. The exercise is about making a navbar with a logo, a title, and a menu button that appears when the screen is small enough.

See example here:

      body {
        font-size: 16px;
        color: #fff;
        background-color: #61122f;
        font-family: 'Oxygen', sans-serif;
      }

      /** HEADER **/
      #header-nav {
        background-color: #f6b319;
        border-radius: 0;
        border: 0;
      }

      #logo-img {
        background: url('https://www.shiva.com/Files/Directory%20Folders/19822_1.png') no-repeat;
        width: 170px;
        height: 150px;
        margin: 10px 15px 10px 0;
      }

      .navbar-brand {
        padding-top: 25px;
      }

      .navbar-brand h1 { /* Restaurant name */
        font-family: 'Lora', serif;
        color: #557c3e;
        font-size: 1.5em;
        text-transform: uppercase;
        font-weight: bold;
        text-shadow: 1px 1px 1px #222;
        margin-top: 0;
        margin-bottom: 0;
        line-height: .75;
      }
      .navbar-brand a:hover, .navbar-brand a:focus {
        text-decoration: none;
      }
      .navbar-brand p { /* Kosher cert */
        color: #000;
        text-transform: uppercase;
        font-size: .7em;
        margin-top: 15px;
      }
      .navbar-brand p span { /* Star-K */
        vertical-align: middle;
      }
  <!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>David Chu's China Bistro</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/styles.css">
    <link href='https://fonts.googleapis.com/css?family=Oxygen:400,300,700' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Lora' rel='stylesheet' type='text/css'>
  </head>
  <header>
    <nav id="header-nav" class="navbar navbar-default">
      <div class="container">
        <div class="navbar-header">
          <a href="index.html" class="pull-left visible-md visible-lg">
            <div id="logo-img"></div>
          </a>

          <div class="navbar-brand">
            <a href="index.html"><h1>David Chu's China Bistro</h1></a>
            <p>
              <img width="25" height="25"src="https://upload.wikimedia.org/wikipedia/en/thumb/1/19/Star-K_logo.jpg/340px-Star-K_logo.jpg" alt="Kosher certification">
              <span>Kosher Certified</span>
            </p>
          </div>

          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#collapsable-nav" 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>

        </div>
      </div>
    </nav>

  </header>


  <!-- jQuery (Bootstrap JS plugins depend on it) -->
  <script src="js/jquery-2.1.4.min.js"></script>
  <script src="js/bootstrap.min.js"></script>
  <script src="js/script.js"></script>
  </body>
</html>

https://jsfiddle.net/8ke1fn7p/2/

I removed the no longer existing classes and replaced them with the corresponding new ones. For the button I used the new sintax showed on bootstrap’s web site.

After these modifications I see two main differences when I have an extra small screen

  1. The h1 title doesn’t go to a new line
  2. The button goes to a new line
  3. The yellow navbar doesn’t extend to the end of the screen

See my result

This is the modified code for Bootstrap v4.5.0

body {
  font-size: 16px;
  color: #fff;
  background-color: #61122f;
  font-family: 'Oxygen', sans-serif;
}

/** HEADER **/
#header-nav {
  background-color: #f6b319;
  border-radius: 0;
  border: 0;
}

#logo-img {
  background: url('https://www.shiva.com/Files/Directory%20Folders/19822_1.png') no-repeat;
  width: 170px;
  height: 150px;
  margin: 10px 15px 10px 0;
}

.navbar-brand {
  padding-top: 25px;
}

.navbar-brand h1 { /* Restaurant name */
  font-family: 'Lora', serif;
  color: #557c3e;
  font-size: 1.5em;
  text-transform: uppercase;
  font-weight: bold;
  text-shadow: 1px 1px 1px #222;
  margin-top: 0;
  margin-bottom: 0;
  line-height: .75;
}
.navbar-brand a:hover, .navbar-brand a:focus {
  text-decoration: none;
}
.navbar-brand p { /* Kosher cert */
  color: #000;
  text-transform: uppercase;
  font-size: .7em;
  margin-top: 15px;
}
.navbar-brand p span { /* Star-K */
  vertical-align: middle;
}
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>David Chu's China Bistro</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
    <link href='https://fonts.googleapis.com/css?family=Oxygen:400,300,700' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Lora' rel='stylesheet' type='text/css'>
  </head>
<body>
  <header>
    <nav id="header-nav" class=" navbar navbar-expand-sm navbar-light">
       <div class="container">
        <div class="navbar-header">
          <a href="index.html" class="float-left d-none d-md-block d-lg-block">
            <div id="logo-img"></div>
          </a>
     
          <div class="navbar-brand"> 
            <a href="index.html"><h1>David Chu's China Bistro</h1>
            </a>
           <p>
            <img width="25" height="25" src="https://upload.wikimedia.org/wikipedia/en/thumb/1/19/Star-K_logo.jpg/340px-Star-K_logo.jpg" alt="Kosher certification" alt="Kosher certification"/>
          <span>Kosher Certified</span>
          </p>
          </div>

         <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>

      </div>
    </div>
  </nav>

</header>


  <!-- jQuery (Bootstrap JS plugins depend on it) -->
  <script src="js/jquery-2.1.4.min.js"></script>
  <script src="js/bootstrap.min.js"></script>
  <script src="js/script.js"></script>
</body>
</html>

https://jsfiddle.net/8ke1fn7p/3/

I did a lot of tries but I couldn’t figure out what the problem is.

Comments

Comment posted by Corrado De Fusco

Thanks a lot for the revision to my question 🙂

Comment posted by Corrado De Fusco

I didn’t express myself very well in my answer. What I figured out is that even classes with the same name do not behave the same way in Boostrap v3.3.6 and Boostrap v4.5.0

By