Navbar struggling to contain overflowing div content

I'm encountering an issue with my navbar responsiveness as it overflows at smaller screen sizes (sm/xs).

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

Although I used the code from the Bootstrap website, I have made some modifications. Could these changes be causing the problem?

Update: including HTML along with CSS

.navbar{
    height: 10.0rem;
    border-bottom: 1px solid rgb(168, 168, 168);
}
.bg-light {
    background-color: white !important;
}
.navbar-collapse{
    padding-left: 0;
}
#navbarNav{
    /* position: relative; */
    width: 50%;
    padding-left: 60%;
}

#options li{
    padding-left: 2rem;
    padding-right: 2rem;
    font-size: 1.2rem;
    font-family: Raleway;
}
li a:hover{
    border-bottom: 1px solid black;
}
.navbar-brand{
    font-size: 4rem;
    padding-left: 3rem;
    font-family: Raleway;
    font-weight: 400;
}
#header-container {
    display: flex;
    flex-direction: row;
    /* justify-content: space-evenly; */
    width: 60%;
    height: 8rem;
    margin: 0;
}
  <nav class="navbar navbar-expand-lg navbar-light bg-light">
    <a class="navbar-brand" href="#">Alan Alban</a>
    <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>
    <section id="header-container">
      <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav" id="options">
          <li class="nav-item active">
            <a class="nav-link" href="/">Experience <span class="sr-only">(current)</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/projects">Projects</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/skills">Skills</a>
          </li>
        </ul>
      </div>
    </section>
  </nav>

I introduced a section container to see if it would extend the screen's length, however, the navbar still "shrinks" when the screen is resized.

Answer №1

When creating the header container with Flexbox, ensure to use the #header-container for better alignment and spacing.

Typically, the default setting for flex-wrap is nowrap, so remember to change it to wrap for a more fluid layout.

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 your mobile site is optimized for full width display

Imagine a webpage with a fixed width of 1280px. Is there a way to instruct a smartphone to automatically scale this page to full width upon loading? Currently, I am using: <meta name="viewport" content="width=1280, initial-scale=1"> However, it d ...

Data input not populating in email

After filling out the form, Gmail pops up with no data entered. How can I ensure that the information I input in the form is transferred to the email? <form class="" action="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_em ...

Vue.js - Problem with loading image on screen

Although I have experience with React, I am currently facing the challenge of using Vue for a code assessment for the first time. My struggle lies in creating a reusable image component with WAI-ARIA accessibility. Despite my efforts, I cannot get the imag ...

Creating a persistent hover effect

Utilizing primarily CSS, along with background images and adjacent selectors, I am creating a page that displays unique human-readable text information when the user hovers over horizontally stacked images. The textual information is presented in a div on ...

CSS for a navigation menu with underlined links

I am attempting to create an underline effect when hovering over a link. However, I am facing an issue where the underline does not align perfectly with the line below it. Can someone please guide me on how to modify this CSS so that when the link is hov ...

Creating adaptable HTML images by specifying width and height attributes within the image tag

My current website setup involves loading a full image and automatically adjusting its size to fit the screen by setting the image width to 100% in CSS. While this method works smoothly, it may not be following standards as I am not specifying width and he ...

Changing the content of a <div> element using the information retrieved from the previous page

When the user clicks the "Edit" button, I am redirecting them from another page using the following code snippet. $('#editListButton').click(function(){ window.location.href = "http://localhost/yyy.php"; //redirect // Modifications th ...

The div element with the id "wrapper" is not functioning properly within the box model

I have defined an ID wrapper in CSS: #wrapper { position: relative; background: yellow; -webkit-box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.2); box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.2); width: 960px; padding: 40px 35px 35px ...

"Utilize PrimeNG's p-tabpanel to bind a unique style class to

When using the tabview component from PrimeNG, I am encountering an issue where I am unable to bind a header style class. Here is my static HTML code that works: <p-tabPanel header="Title" headerStyleClass="badge" formGroupName=&quo ...

AngularJS Partial Views: Enhancing Your Website's User Experience

As a newcomer to the world of Angular, I am seeking guidance on a specific issue. I have encountered a one-to-many relationship scenario where one Category can have multiple Product items. The challenge lies in my layout page setup where I display various ...

Issues with script execution on Ajax tab

I'm currently using JQuery UI tabs to load content through Ajax. I have a situation where two tabs are supposed to load HTML content and execute a script to hide or show certain elements in the loaded content. However, I encountered an issue where the ...

"Utilizing images within an iframe: A step-by-step guide

I'm trying to integrate an iframe into a phone image with a transparent background. However, I am unsure how to effectively mask the iframe so that it only appears within the boundaries of the phone image. .phone { display: block; position: r ...

What is the best way to achieve a full width table in an HTML format on a smartphone browser?

Apologies for my limited English proficiency. I am currently working on creating a horizontal scrollable table in HTML. My goal is to make the width of the table span beyond the browser's viewing area, so that sticky cell functionality can be implem ...

Unable to adjust the dimensions of a Mailchimp input field

Having some trouble customizing my Mailchimp form a bit and could use some assistance. Snippet of the code: <!-- Begin MailChimp Signup Form --> <link href="//cdn-images.mailchimp.com/embedcode/horizontal-slim-10_7.css" rel="stylesheet" type=" ...

"Keep the div locked to the screen when the bottom of the div aligns with the

Hey everyone! I'm currently grappling with a project that requires me to keep a div stuck to the screen (prevent scrolling) when its bottom reaches the bottom of the screen. I have two divs on the page, both with varying heights. My aim is to keep div ...

Image swaps with timer for button

I am working on a project where I have a page with 5 image buttons arranged horizontally. The objective is to have the images on each button change sequentially every 3 seconds in a continuous loop. Here is my code: $(document).ready(function (){ Beg ...

Tips for automatically adjusting the width of dt and dd elements using CSS

My approach to creating a paper form involves using dt and dd elements. The width of dt should align with the word, while dl should occupy the remaining space. Currently, I manually adjust each line, but I am looking for a way to automate this using CSS. ...

Is there a way to enlarge an iFrame to fill the entire screen with just a button click, without using JavaScript

I am currently attempting to achieve full screen mode for an iFrame upon clicking a button, similar to the functionality on this site. On that website, there is a bar that expands to full screen along with the embedded game, which is what I am aiming for. ...

Vue.js is displaying one less item

Recently I started working with Vuejs and encountered an unexpected issue in my application. The purpose of my app is to search for channels using the YouTube API and then display those channels in a list. However, when I try to render the list of subscri ...

particular shade for button border and background

I'm looking to create a button using Material UI that has a specific design. Right now, I've only been able to achieve this: https://i.stack.imgur.com/xvv7s.png Here is the code I am currently using. If anyone can help me identify what I'm ...