Why isn't my Bootstrap navbar expanding properly?

I am facing an issue with my toggle menu where it is not dropping down as a solid black block but instead in the center transparent. How can I fix this to make it drop down as a solid block and be positioned to the left? I have a bootstrap navbar that I modified with external CSS. Despite my efforts to find a solution, I am struggling to resolve the problem. As someone who is new to HTML, CSS, and Javascript, I might not be accurately describing the problem for Google search. Hopefully, someone here understands my issue. Thanks!

 .navbar {
     background-color: black;
     height: 15%;
     line-height: 280px;
}
 li {
     padding-right: 10px;
     padding-left: 10px;
}
 .collapse {
     display: flex;
     justify-content: center;
     text-align: center;
}
 .nav-link {
     color: white !important;
     font-weight: bold;
     font-size: 120%;
     font-style: italic 
}
 .poetry-monkey-logo-center {
     height: 15px;
}
 .poetry-monkey-logo-center>img {
     height: 120px;
     width: 130px;
     border: 10px solid black;
     border-radius: 80%;
     margin-top: 40px;
}
/* Remaining CSS styles */

Here is my HTML code:

<!DOCTYPE html>
<html lang="en-us">
   <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
      <title> PoetryMonkey.com</title>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
      <!-- Included scripts and links -->
   </head>
   <body>
      <nav class="navbar fixed-top  navbar-expand-sm navbar-light p-3 mb-2" >
         <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
         <span class="navbar-toggler-icon"></span>
         </button>
         <div class="collapse navbar-collapse "  id="navbarNav">
            <ul class="navbar-nav">
               <li class="nav-item active">
                  <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
               </li>
               <!-- Other navbar items -->
            </ul>
         </div>
      </nav>
      <!-- Jumbotron and poem sections go here -->
      <!-- Footer section -->
      <footer class="footer-bs">
         <!-- Footer content goes here -->
      </footer>
      <!-- Optional JavaScript -->
      <!-- Scripts included at the end -->
   </body>
</html>

Answer №1

It doesn't seem logical why extra CSS has been added to the collapse class, causing everything to center and navigation links can be made visible by adding some media queries and removing excessive line-height.

.navbar {
     background-color: black;
     height: 15%;
     line-height: 280px;
}
 li {
     padding-right: 10px;
     padding-left: 10px;
}

 .nav-link {
     color: white !important;
     font-weight: bold;
     font-size: 120%;
     font-style: italic 
}
 .poetry-monkey-logo-center {
     height: 15px;
}
 .poetry-monkey-logo-center>img {
     height: 120px;
     width: 130px;
     border: 10px solid black;
     border-radius: 80%;
     margin-top: 40px;
}
/* Remaining CSS code removed for brevity */
<!DOCTYPE html>
<html lang="en-us">
   <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
      <title> PoetryMonkey.com</title>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
      <script>
         $(document).ready(function(){
             // JavaScript code omitted for brevity
         
         });
      </script>
      <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
      <link rel="stylesheet" href="assignment-5.css" type="text/css" media="all">
   </head>
   <body>
      <!-- Navbar start -->
      <nav class="navbar fixed-top  navbar-expand-sm navbar-light p-3 mb-2" >

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

Ensure the width of ancestor flexbox divs is limited to the width of its child by setting a specific width

I have a specific element that incorporates flex display and I've defined its width with the flex-basis property like this: .flex-row input { flex: 0 1 450px; } There is a flex-row division nested inside a flex-container division. My goal is for th ...

Curved divs display outlines on more compact dimensions

Check out this relevant Codesandbox There seems to be a recurring issue in my application where rounded divs display edges when they are of smaller sizes. Refer to the image below for a visual representation. What could be causing this problem and how can ...

Mobile-friendly website with consistent design across all devices

Can you help me figure out how to make my website appear at its normal size on mobile devices? I want the entire website to be visible without the need for scrolling, but still allow users to zoom in if needed. I've already tried: <meta name=" ...

Instead of displaying an error page, an Axios post request is returning data

I'm currently dealing with a post request that looks like this: axios({ method: "post", url: "/sessions/add", data: { session: { name: session.session.name, date: sessionDateInput.value, ...

If a table column lacks an unspanned cell, IE will disregard its width

Here is a visual representation of the issue I am facing: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <body> <table border="1"> <colgroup> <col ...

"An innovative social media platform feature resembling a Linkedin/Facebook post box

I am looking to develop a post box feature similar to LinkedIn and Facebook. When a URL is pasted into the box, I want a thumbnail to be generated. Two main questions: - Is there an existing component that already does this? I have searched extensively b ...

Elements being impacted by the CSS Transition are being pushed

I am facing a CSS issue that I just can't seem to resolve. If you visit and check out the top search bar. On hovering over it, you'll notice it resizes to fit the content width. This is the CSS code responsible for this: .header .search-wrap ...

The issue with Ajax.BeginForm OnSuccess is that it prevents the CSS transition from functioning properly

Apologies if the title is unclear. In my design, I aim to implement a transition effect when the left or right buttons are clicked. However, the transition does not function as expected because the OnSuccess callback seems to occur before the page is rend ...

Ensure that the width of the inner table matches the width of its contents within an overflowing div

I'm facing an issue with a table inside a div styled as table-wrapper: .table-wrapper { display: inline-block; overflow-x: scroll; width: 800px; } Although I want the div to display a horizontal scrollbar so that the table inside it can ...

Enhancing react-input-range with unique Custom Arrow heads

I'm currently working with react-input-range to create a price range slider. While I've managed to customize the CSS of the range slider, I now need to figure out how to add arrow heads inside the circles as shown below: Any guidance on how I ca ...

Position images inside a stylish border using CSS styling

//UPDATE: I've made some changes to the Pen, so now everyone can view the solution! Check it out here. My goal is quite simple in my opinion. I want to create an image that zooms in when you hover over it but doesn't increase in size. I attempte ...

Hover over with your mouse to open and close the dropdown menu in React JS

Just starting out with React JS and encountering a small issue. I'm trying to make the menu disappear when the mouse leaves that area, so I used onMouseOut and onMouseLeave to close it. However, I noticed that having these options in place prevents th ...

Utilizing CSS to dynamically update SVG icons within the navigation menu upon tab selection

Feeling frustrated and in need of assistance with my current issue. I am attempting to make a change - when I click on a tab in the menu, the default black SVG icon should be replaced by a white one. #menu a .main-menu-icon { display:inline-block; width:2 ...

What causes the empty gap to appear during animated transitions between two 'div' elements?

Is there a way to eliminate the white space in between elements during animation? Should I wrap both divs into another div to achieve this? I am using position-top to adjust my div animations. Could this be causing the issue? What other methods can you s ...

premature submission alert on button press

I'm encountering an issue where my form is being submitted prematurely when I click on the button. The desired behavior is for the button to create a textarea upon clicking, allowing me to write in it before submitting by clicking the button again. Ho ...

What is the best way to perfectly center text within an image, maintaining both vertical and horizontal alignment, all while being contained within an <a> tag?

I've been working with this code snippet. When I set the position of .thumb-title to absolute and use bottom: 50%, it shifts upwards in relation to its own height. .project-thumb { position: relative; } .thumb-title { font: 400 1.5rem 'La ...

Aligning elements next to each other in html / css without using any top margins

How can I arrange four blocks of text side-by-side, center them over a background image, and ensure they respond well on different screen sizes without using tables? I typically use tables for this layout, but I've heard that CSS/HTML5 can achieve th ...

Applying CSS rules from an array to elements by looping through

I'm looking for a way to allow users to input CSS styles and have those styles applied to the last selected element, which is determined by the "rangeselector" variable. Currently, the code selects the correct element, but only the first CSS rule is b ...

View the picture directly on this page

Currently, I am in the process of creating a gallery and I would like the images to open on top of everything in their original size when clicked by the user. My expertise lies in HTML and CSS at the moment, but I am open to learning JavaScript and jQuery ...

JavaScript takes the spotlight before CSS

Currently experiencing this issue in Chrome, although Firefox seems to be working fine so far. Here is a greatly simplified version of the problem: HTML: <div class="thumbnail"> <a href='#' id="clickMe">Click me!</a> </d ...