Guide to incorporating a Menu feature into your MVC 5 application

After creating an MVC 5 project, the decision was made to change the menu by incorporating Bootswatch. The desired menu to implement is displayed below:

https://i.sstatic.net/2vqxn.png

The initial step involved modifying the general style of the project which entailed downloading the bootstrap.css file as shown here:

https://i.sstatic.net/8QZUc.png

Subsequently, the bootstrap.css file was swapped with BundleConfig to alter the style of the project. However, the desired navbar was not included as anticipated:

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

To implement the desired Navbar, the following code was inserted into the _Layout.cshtml file:

<!DOCTYPE html>
<html>
<head>
   <meta charset="utf-8" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>@ViewBag.Title - Muebles Pangal</title>
   @Styles.Render("~/Content/css")
   @Scripts.Render("~/bundles/modernizr")
</head>
<body>
   <div class="container">
       <nav class="navbar navbar-expand-lg navbar-dark bg-success">
           <a class="navbar-brand" href="#">Muebles Pangal</a>
           <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation" style="">
               <span class="navbar-toggler-icon"></span>
           </button>
           <div class="collapse navbar-collapse" id="navbarColor01">
               <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="@Url.Action("Index", "Categorias")">Categorias </a>
                   </li>
                   <li class="nav-item">
                       <a class="nav-link" href="@Url.Action("Index", "Productoes")">Productos </a>
                   </li>
                   <li class="nav-item">
                       <a class="nav-link" href="@Url.Action("Index", "Ubicacions")">Proveedores </a>
                   </li>
               </ul>
               <form class="form-inline my-2 my-lg-0">
                   <input class="form-control mr-sm-2" placeholder="Buscar" type="text">
                   <button class="btn btn-secondary my-2 my-sm-0" type="submit">Buscar</button>
               </form>
           </div>
       </nav>
       </div>

       <div class="container body-content">
           @RenderBody()
           <hr />
           <footer>
               <p>&copy; @DateTime.Now.Year - Sistema Bodega</p>
           </footer>
       </div>

       @Scripts.Render("~/bundles/jquery")
       @Scripts.Render("~/bundles/bootstrap")
       @RenderSection("scripts", required: false)
</body>
</html>

Upon executing the project, it was noticed that the menu did not perform effectively with responsive calls. Specifically, upon changing the browser size and calling the menu, the

<span class = "navbar-toggler-icon"> </ span>
would briefly display but immediately collapse:

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

This issue persisted despite various attempts to rectify it. Bootstrap and Bootstrap.less packages have been installed, yet the problem remains unsolved. Assistance in resolving this matter would be greatly appreciated. Any suggestions?

Is there any help available for this issue?

Answer №1

It seems like you may be missing jQuery.min.js or it could be incorrectly placed in your code structure. I hope this code snippet helps you out!

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>

<nav class="navbar navbar-expand-lg navbar-dark bg-success">
    <a class="navbar-brand" href="#">Muebles Pangal</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation" style="">
                <span class="navbar-toggler-icon"></span>
            </button>
    <div class="collapse navbar-collapse" id="navbarColor01">
      <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="@Url.Action(" Index ", "Categorias ")">Categories </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="@Url.Action(" Index ", "Products ")">Products </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="@Url.Action(" Index ", "Locations ")">Suppliers </a>
        </li>
      </ul>
      <form class="form-inline my-2 my-lg-0">
        <input class="form-control mr-sm-2" placeholder="Search" type="text">
        <button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
      </form>
    </div>
  </nav>

Answer №2

Could you please review your CSS for the following:

.navbar-collapse.collapse {
        display: none!important;
    }

I managed to create a functional menu in a new MVC 5 project using the code you provided, but my CSS may be different from yours.

For a similar issue, you can refer to this problem: Bootstrap mobile menu wont stay open

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

Tips for ensuring a flexbox stays within the bounds of its container and doesn't exceed the available space

I am in the process of developing a modal that needs to be centered on my page and expand organically, but only up to a specific width and height limit. Using flexbox, I have successfully centered this modal (.modal) on the page. Within the modal, there ...

Struggling with aligning HTML tabs in Django framework

https://i.sstatic.net/vsnqD.pngI have been working on displaying a list of data based on tabs. I have successfully retrieved the data and shown it, but the issue lies in the HTML structure. Certain parts of the HTML should not repeat, but they need to appe ...

Display of menu content may be unavailable at certain screen resolutions

Upon creating a new project in Visual Studio 2017, I developed a default master and sub pages website. In the master page, I incorporated a menu using a mix of divs and tables. Everything functions properly except for when the window size is reduced to a ...

What is the best way to activate CSS filters on VueJS once the project has been compiled?

While working on a Node server locally, my SVG filter functions properly. However, once I build the project and run it on a server, the filter stops working. This VueJS project is utilizing Webpack as its build tool. The process of building the app invol ...

Creating personalized static HTML cards with PHP Mirror API for Google Glass

Looking to integrate an HTML formatted card into Google Glass timeline using the Mirror API. Utilizing the PHP PHP Mirror Client API, which accepts a message and image as parameters, displaying the image in the background similar to this example: insert ...

Using Javascript code to draw particles at the cursor's position and then directing those particles towards the bottom of

I found an interesting JavaScript code snippet that creates a bubble particles effect around the cursor. You can download it from https://github.com/tholman/90s-cursor-effects. However, I encountered a problem when adding certain elements inside a specifi ...

Employ a distinct styling approach for Chrome and Mozilla with only utilizing a single style

This is the CSS style defined in a PHP file for an Element line-height: 120px; display: list-item; display: -moz-inline; list-style: none; If the browser is Chrome, I want it to show display: list-item, and if it's Mozilla, then display: inline. Th ...

Activate the overflow feature within native-base cards

I have a unique design element on a website that showcases an image overflowing off a card. The image has a negative margin-top of -50, creating this effect. Now I'm trying to replicate this design in react-native using native-base components. Here i ...

Creating full-width divs using BootstrapLearn how to easily create full-width div

Bootstrap is being utilized in my current project. I have been creating divs inside columns, but they are not extending to the full width of the columns. Below is a snippet of the code: <!DOCTYPE html> <html lang="en"> <head> ...

Troubleshooting problem with AngularJS ng-repeat

Seeking assistance with an angularjs issue as a newcomer to the platform. Building a photo gallery where the initial page displays thumbnail photos from twitter and instagram using ng-repeat loop. Hovering over an image fades it out, revealing a button f ...

Display a string of text containing multiple interactive links

I have a table and I want to create an interactive effect where, upon mouseover or click of certain elements, text will appear next to it. This text may contain multiple lines and clickable links within the content. For instance, in the table generated by ...

The Faux-Dynamic News Feed on a stationary website

As I work on revamping my employer's static website, it has become clear that a news section needs to be integrated. The site is being built using the Bootstrap 3.0 framework. My plan is to implement the following strategy: I aim to have a JavaScrip ...

Toggle button to collapse the Bootstrap side bar on larger screens

I am currently utilizing the following template: An issue I am facing is that I want my sidebar to either shrink or hide when a button is clicked, specifically on a 22" PC screen. I have experimented with several solutions without achieving success. Alt ...

Simple Bootstrap Input Slider Configuration

I am attempting to create a simple setup for a bootstrap-style input slider, but I am facing some difficulties getting it to function properly. Desired Outcome: https://i.sstatic.net/Btfo3.png Actual Outcome: https://i.sstatic.net/0VnNv.png Resource / ...

When the mouse is clicked, the character fails to reach the intended destination or moves in the wrong direction on the HTML canvas

UPDATE: RESOLVED I am currently working on a game where the character moves by right-clicking. The character is meant to walk slowly, not teleport, towards the destination set by right-clicking on the canvas. However, I have encountered an issue where the ...

Show the selected values of different checkboxes

Can anyone assist me with jQuery? I have an easyui accordion containing text and checkboxes, with multiple inputs within each accordion. The values of the inputs are retrieved from PHP arrays. I am trying to display the value of each input when checked ( ...

Is it possible for me to adjust these two images to fit the screen perfectly?

Technologies: CSS React JPG/PNG Objective: I am striving to resize two images to achieve this desired look: https://i.stack.imgur.com/B1b0h.png I am currently developing a 'skirt customizer' for either my mom or portfolio, where users can m ...

Unusual behavior being exhibited by the background in an HTML5 canvas

I have an 800 by 100 image for the background and I'm trying to extract sections from it (like a sprite sheet) in order to create a background. I believe this method is efficient and allows me to experiment and learn how to generate backgrounds in the ...

Jquery failing to function properly when scrolling

I have been attempting to implement a feature where an element changes its position to fixed after scrolling past a certain point. However, no change occurs when I scroll. In the <head> section of my code, I have included <script src="stiler/jquer ...

Troubleshooting an Issue with jQuery UI Accordion

Having some trouble getting the jQuery UI accordion to work on my fields. Any advice on how to fix this issue? Check out my Codepen $(function() { $( "#accordion" ).accordion({ collapsible: true }); }); ...