Differences in appearance between Bootstrap 3.7 and the most recent Bootstrap (4) version causing styling concerns

I recently downloaded some code from Coursera for a Responsive Web Design course to experiment with toggling navbars. The code, which appears to be based on Bootstrap version 3.7 (included in the class materials), works perfectly fine.

However, after downloading the latest version of Bootstrap, I encountered display issues with the code. I am struggling to identify the root cause of this problem. I have attached screenshots for reference. In the incorrectly displayed versions, clicking the small flat button briefly reveals the other elements before disappearing within half a second. Many other students have reported encountering the same issue on the forums, but none of the moderators or mentors have been able to provide a solution. Therefore, I am reaching out here in hopes that someone can assist me!

What could be causing this issue? Are there classes or properties in the newer Bootstrap version that are not compatible with the code?

Here is how the page should look with Bootstrap ~3.7:

https://i.sstatic.net/4bisX.png

Here is how it appears with Bootstrap 4.2, displaying incorrectly:

https://i.sstatic.net/7Jhm0.png

And here is how it looks with the new Bootswatch theme (Slate), also displaying incorrectly:

https://i.sstatic.net/z2pit.png

<!DOCTYPE html>
<html lang="en">
  <head>
   <title></title>

    <link href="css/bootstrap.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and     media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file://     -->
    <![if lt IE 9]>
      <script     src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js">    </script>
    <![endif]-->
  </head>
  <body>

      <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
              <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="#">Edward MonteVerde</a>
      </div>
      <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav">
          <li class="active"><a href="#">Home</a></li>
          <li><a href="#">CV</a></li>
          <li><a href="#">Portfolio</a></li>

          <!-- dropdown menu -->

          <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" 
                aria-expanded="false">Contact <span class="caret"></span></a>
            <ul class="dropdown-menu">
              <li><a href="#">Email</a></li>
              <li><a href="#">Skype</a></li>
              <!-- additional item in dropdown -->
            </ul>
          </li>

          <!-- end of dropdown menu -->

        </ul>
      </div><!--/.nav-collapse -->
    </div><!--/.container-fluid -->
  </nav>


<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>

   </body>
</html>

Answer №1

IMPORTANT: If your paid professors or mentors are unable to assist you in resolving this fundamental issue, it may be time to reconsider paying for their services and seek a refund for any fees already provided.

Typically, upgrading to a "major" version of a tool requires significant modifications to your application's code. This guideline applies to any system that utilizes version numbers (such as most software, particularly those on npm). The "major" version is indicated by the number on the far left of the version string.

v2.3
v3.1
v4.21

To understand more about semantic versioning, visit: https://semver.org/

In this scenario, transitioning from major version 3 to major version 4 involves numerous changes compared to the code you previously shared. I have prepared an updated code example showcasing the changes made to the bootstrap navbar in version 4. Here is a fiddle demonstrating the adjustments (adjust the preview panel size to see the transition from hamburger icon to expanded menu).

https://jsfiddle.net/m8gfhr95/

Below is a basic snippet featuring the classes used in the nav element, along with the li and a elements:

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <a class="navbar-brand" href="#">Navbar</a>
  <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 class="collapse navbar-collapse" id="navbarSupportedContent">
    <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>
    </ul>
  </div>
</nav>

Answer №2

Are there any differences in classes/class properties between the latest Bootstrap versions?

Absolutely. Bootstrap undergoes major updates between version changes, such as transitioning from float to flex for the Grid System in Bootstrap 4. Additionally, class names have been altered (e.g., pull-right is now float-right).

It's important to note that snippets used in previous versions may not necessarily work in newer releases, requiring adaptation.

If you encounter a default snippet from Bootstrap 3, consider referring to the version 4 documentation instead, as the examples usually remain consistent. Alternatively, consult the migration guide for guidance on transitioning elements like nav between versions. Ultimately, starting with a Bootstrap 4 snippet and adjusting it to fit your design might be the most effective approach.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to ensure that Bootstrap columns are spacious enough to fit advertisements?

Using Bootstrap 5, I have created a page layout with 3 columns: <div class="container"> <div class="row"> <div class="col-md-3">LEFT</div> <div class="col-md-6">CENTER</div& ...

A convenient method for converting horizontal columns into vertical columns on mobile screens without using <div> tags or setting a minimum width, perfect for email formatting

After experimenting with using <div> elements and applying a min-width attribute to an email, I have come to the conclusion that these methods do not yield satisfactory results. While the alignment of horizontal columns works well on desktop screens, ...

Altering the "src" property of the <script> tag

Can the "src" attribute of a current <script> element be altered using Jquery.attr()? I believed it would be an easy method to enable JSONP functionality, however, I am encountering difficulties in making it operate effectively. ...

Directing BeautifulSoup to a specific <tr> class

I'm currently working on a project where I need BeautifulSoup to extract the numbers located in the "Units Sold" column: from bs4 import BeautifulSoup from urllib import urlopen html = urlopen('http://www.the-numbers.com/home-market/dvd-sales/2 ...

How to optimize the loading speed of background images in an Angular application

Utilizing Angular v6, typescript, and SASS for my project. A CSS background image is set for the homepage, however, it's a large photo that always takes too long to load. Custom CSS: @import '../../../scss/variables'; :host { .wrapper { ...

What is the correct way to show a JavaScript response on the screen?

Here is the JavaScript code I used to call the server API: <script type='text/javascript'> call_juvlon_api(apikey, 'getAvailableCredits', '', function(response) { document.getElementById('show').innerHT ...

What is the process for setting up a bootstrap grid with a single column at the top and two columns

Can anyone help me figure out how to rearrange a bootstrap grid from three columns on desktop to one column above and two below on mobile? I've attempted multiple methods, but haven't had any luck... https://i.stack.imgur.com/oY2VU.png ...

Time whizzes by too swiftly

After attempting to create an automated slideshow with clickable buttons, I encountered a problem. The slideshow functions properly, but as soon as I click one of the buttons, the slideshow speeds up significantly. This is what I implemented in my attempt ...

Tips for troubleshooting a sass file that is not displaying changes in the browser

Currently working on my portfolio website using bootstrap and sass along with a theme kit. Initially, I attempted to implement a grid column style for the intro-section but had a change of heart and deleted the style. Surprisingly, every time I refresh my ...

Crafting a unique datalist from an XML file with the help of jQuery

<mjesta> <mjesto>Zagreb</mjesto> <mjesto>Split</mjesto> <mjesto>Ploce</mjesto> <mjesto>Pula</mjesto> <mjesto>Pazin</mjesto> <mjesto>Daruvar</mjesto> <mjesto>Bjelovar</mj ...

Tips for eliminating the horizontal scroll bar within SweetAlert2's popup?

Here is the HTML code containing a date picker popup implemented using SweetAlert2: <!DOCTYPE html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name=" ...

What is the process for indicating a specific spot on Google Maps?

Hello, I am a new programmer trying to indicate the location of my company. The map pointer is not showing up even though the location is correct. I have tried numerous solutions but none seem to be working. Any assistance would be gre ...

What is preventing me from setting the height of a span to 0 pixels?

It seems that when the height is set to 0px, the element doesn't visually shrink... <div id="bg"> <div id="animate"><span>WINNER ALERT! Click here to get a million dollars!!!</span></div> </div> #bg { back ...

Showcasing images in Flask

Hello everyone, I am encountering an issue with displaying images in my HTML file. Currently, I am using Flask within Visual Studio Code and here is the code snippet that I want to display: <img src="/templates/WANG_CHONG_st_1.png" width=" ...

In-depth preg_match_all analysis

I'm encountering an issue with my detailed preg_match_all not working as expected. Instead of retrieving the desired data, I am getting a blank Array. Below is the code snippet I'm struggling with: <?php $remote_search = file_get_content ...

What is the Best Way to Create a Form Inside a Box?

Hello there! I am trying to create a form underneath the box labeled "New Referral," but I'm having trouble figuring it out. I would like to include sections for first name, last name, date of birth, phone number, email, and address under the box. Any ...

Exploring the object tag box model and its properties for width and padding in Firefox version 6

Hey there, I've been puzzled by the fact that my Firefox browser seems to be using a different box model for my video embeds compared to Chrome. Even though the same CSS rules are being applied, if the object tag includes attributes like data="whateve ...

measurement of the <div> element's vertical dimension

Included in my page are 2 divs: <div id="firtdiv" style="top:100px; left:200px; height:unknown"></div> <div style="top:unknow; height:200px" id="seconddiv"></div> The height of firstdiv will be set to auto as a datalist will be pla ...

Can I use AJAX to load an entire PHP file?

My goal is to trigger a PHP file for sending an email when the countdown I created reaches zero. The PHP code contains the email message and does not involve any UI elements. I suspect that my approach may be incorrect, especially since I am not very fami ...

Is there a way for me to view the contents within the box?

Hey there! I have a question about how to access the content inside this mysterious box "" within the style sheet. For instance, I am curious to find out the link of the image: .facebookicon::before { content: ""; } ...