What could be the reason for my navbar menu getting cropped?

I have been tasked with making modifications to a website that was created using Bootstrap v3.3.7. The site includes a navbar (HTML provided below) that appears fine. However, I needed to add a dropdown item to the navbar, which I did by following the guidelines on the Bootstrap page. The HTML code is essentially the same as what I have used successfully in other instances.

Yet, when I click on the dropdown option in this specific case, the menu gets cut off...

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

You can only see the top part of the first item in the menu, and nothing more.

Could someone please explain why this issue is occurring? Here is the HTML for the navbar:

<div class="navbar navbar-default navbar-fixed-top">
  <div class="container">
    <div class="row">
      <div class="col-md-4 col-sm-4">
        <div class="site-title">
          <h3>My web site</h3>
        </div>
      </div>
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" 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 class="col-md-8 col-sm-8 navbar-style">
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav">
            <li><a href="...">Link 1</a></li>
            <li><a href="...">Link 2</a></li>
            <li><a href="...">Link 3</a></li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown">Colours <b class="caret"></b></a>
              <ul class="dropdown-menu">
                <li><a href="#">abc</a></li>
                <li><a href="#">def</a></li>
                <li><a href="#">ghi</a></li>
              </ul>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</div>

Answer №1

Unfortunately, I am unable to leave a comment at this time, so I will share my thoughts and suggestions here.

  • The neophyte appears to indicate that the code is functioning correctly. Please review your CSS styles to ensure there are no issues such as overflow: hidden on your header.

  • I am uncertain if the black background is intentional in your modification with menu cut off here. If not, it may be due to overflow in your header.

  • Please provide us with your CSS styles as well for further assistance.

Answer №2

<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  </head>
  <body>
    <div class="navbar navbar-default navbar-fixed-top">
      <div class="container">
        <div class="row">
          <div class="col-md-4 col-sm-4">
            <div class="site-title">
              <h3>My website</h3>
            </div>
          </div>
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" 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 class="col-md-8 col-sm-8 navbar-style">
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
              <ul class="nav navbar-nav">
                <li><a href="...">Link 1</a></li>
                <li><a href="...">Link 2</a></li>
                <li><a href="...">Link 3</a></li>
                <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Colours <b class="caret"></b></a>
                  <ul class="dropdown-menu">
                    <li><a href="#">abc</a></li>
                    <li><a href="#">def</a></li>
                    <li><a href="#">ghi</a></li>
                  </ul>
                </li>
              </ul>
            </div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>

It is functioning correctly for me. Please refer to the snippet above. The issue might be related to a CDN problem where it could have been included twice on your page.

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

Implementing AngularJS to trigger a Jquery Bootstrap Confirm Box when a button is clicked

Being a beginner in AngularJS, I am not familiar with its events. Currently, my project requires the use of jQuery bootstrap library. What I need is to trigger the bootstrap confirmbox when clicking on a button, and based on the user's response (ok or ...

Is there a way to modify the size and color of a specific word in a CSS animation?

As a newcomer to CSS, I am exploring ways to change the font size and color of a specific word in my sentence after an animation. My initial attempt was to enclose the word within a span class like this: <h2>I'm <span style = "font-size: ...

What could be causing the DIV elements to not align side by side?

<div id="dvFirst" class="mainSecond" style="background: #6FA5FD;"> <div id="leftdiv3" class="leftdiv">Client: </div> <div id="rightdiv3" class="rightdiv"><asp:DropDownList ID="ddlCliNewMsg" AutoPostBack="t ...

What is the best way to add animation to the hide/show function?

<div class="overlay"></div> CSS: .overlay::after { position: fixed; top: 0; left: 0; width: 100%; content: ""; z-index: -1; height: 100%; transit ...

Ways to customize the appearance of a search box

I am looking to revamp the appearance of a search bar that currently looks like this: <div class="searchbase input-group animated trans" id="searchbase"> <input type="text" placeholder="<?php _e(_l('Searching...'));?>" class=" ...

Tips for adding a background image to your website

I am attempting to use a URL for a Background Image: However, my approach is not working as expected. Here is the code snippet: body { background-image: url("https://homepages.cae.wisc.edu/~ece533/images/airplane.png"); background: linear-gradient( ...

Having trouble with Firefox's functionality when dealing with Unicode characters

My goal is to make a unicode character toggle the visibility of another span element when hovered over. This functionality works in Chrome but not in Firefox. Below is the HTML code I am using: <span class="default" id="some_id"> <b id="anot ...

Out-of-stock contact form button for WooCommerce

Our webshop needs a button added to every out-of-stock product page. I've tried adding the code below, but the button appears on all products, including those that are in stock. Can someone provide guidance on how to fix this issue? Appreciate any he ...

Create spinning wheel - canvas

Hey there! I'm trying to create a cool spinning wheel using a canvas and JS. My wheel is supposed to have 10 segments, each saved as a .png file. https://i.sstatic.net/glN1p.jpg In order to achieve a "full circle", I want to draw these 10 segments i ...

issues with adding class to div element

I have a div section that contains various movie items and overlay elements. <div class="overlay"> <a title="yes" href="#"><div class="yes"></div></a> <a title="no" href="#"><div class="no"></div>< ...

Tips for removing CSS and Javascript code from a website's source code

After implementing the Slicknav Menu plugin on my website, I noticed that a portion of the plugin's CSS and script code is visible when inspecting the source code of the main page: <head> ... <style id='slicknavcss-inline-css&apo ...

What is the best way to ensure that two checkboxes are mandatory out of a total of three in

<input type="checkbox" name="Package1" value="packagename"> <input type="checkbox" name="Package2" value="packagename"> <input type="checkbox" name="Package3" value="packagename"> Is there a way to require the user to select at least t ...

Center alignment of text and images within the button's image

Can someone help me format my CSS properly? I have a button image where the text should be on the left side and another image on the right side. Currently, everything is centered. Thank you in advance. Here is the current code: button { /* padding- ...

What could be the reason for the checkbox being toggled twice?

Here is the code snippet I am working with: $("input[type='checkbox']").each(function() { var current = $(this); $("label[for='" + current.attr("id") + "']").on('click', function() { current.change(); al ...

Problem with jQuery hoverIntent and toggling visibility for a div

Hey there! I have a little div that I like to display to users every time they add something to their shopping cart. It pops up on the page for 5 seconds and then disappears. This mini cart display is activated by two events: HOVER: When a user hovers o ...

Activating two buttons in jquery will trigger this action

I am currently working on developing a filter button that will perform different actions based on which buttons are pressed. Pressing button1 will trigger one action, while pressing button2 will trigger another action. If button1 is pressed first, followe ...

Develop a JSON structure that represents an array of dynamically generated fields in PHP

Need help converting data from a PHP form into a specific JSON format. Struggling to create the right array that can be easily converted into JSON format. Here is a snippet of the array structure: Array ( [user_id] => [title2] = ...

Step-by-step guide on achieving 100% height for a child element within a parent using Flexbox

Currently facing an issue where trying to make a child element take up 100% of the remaining height of its parent container causes the child's height to go beyond the boundaries of the parent. HTML .container { height: 340px; /* background-i ...

Customize cell options in a dynamic grid within a dojo environment

When I double click on a cell in a data grid, I want to display a dropdown with information from a dojo store. However, the code I am using is not working as intended. I need to show clinician IDs stored in "clinStore" in the 'clinicianId' field ...

Choose from the selection of options in the select tag

In my HTML document, I am working on a feature where selecting an option from one select tag should dynamically populate another select tag with specific options based on the selection. This is the code snippet I have implemented: <script type ...