Obscured by the overflow

How can I make my navbar stay sticky at the top all the time while scrolling without the content of my cards overlapping it? I am using Bootstrap 5 and have tried setting the position to sticky and overflow to hidden, but the issue persists. Any suggestions?

nav {
  background-color: black;
  position: sticky;
  overflow: hidden;
  top: 0px;
  padding: 0;
  border: 2px solid green;
}

.nav {
  color: lightgrey;
  float: left;
  margin: 1vw;
}
<nav>
  <a href="../../index.html" class="nav">Home</a>
  <a href="./products.html" class="nav">Products</a>
  <a href="./about.html" class="nav">About us</a>
  <a href="./contact.html" class="nav">Contact</a>
</nav>

<main class="container">
  <div class="row gy-3">
    <div class="col-md-3">
      <div class="card">
        <img src="https://via.placeholder.com/99" class="card-img-top" alt="...">
        <div class="card-body">
          <h5 class="card-title">Card title</h5>
          <p class="card-text">Some quick example text
           to build on the card title and make up the 
            bulk of the card's content.</p>
          <a href="#" class="btn btn-primary">Go somewhere</a>
        </div>
      </div>
    </div>
  </main>

I also tried putting the image in a div inside the card with overflow:hidden, but that didn't solve the issue.

Answer №1

In case you want the navigation bar to stay at the top of your screen continuously, consider using position: fixed instead of sticky

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

Searching and categorizing information within a table using jQuery

Can someone help me with merging my html and jquery code for type and filter table data, as well as tag data in the same input box? I have the code for both functionalities separately (http://jsfiddle.net/tutorialdrive/YM488/), but I want to combine them. ...

Pressing a button will display a div element, which will automatically be hidden after 5 seconds

I'm working on an email submission form that displays a confirmation message below the input field when a user submits their email address. The confirmation text should fade out after 5 seconds. Here's the code snippet: <div class="input-gro ...

How can I optimize webkit-mask-box-image with a high-resolution Retina image?

Hey there, wondering if it's possible to achieve high-quality Retina-level CSS masking with the -webkit-mask-box-image property. Specifically, I'm trying to round the corners of an element without using border-radius due to performance issues: . ...

The contents of the multi-level navigation are automatically shown as the page loads

I've implemented a multilevel dropdown menu on my website using a plugin, and it works as expected. However, there's an issue where the contents of the dropdown menu display for a brief moment while the page is loading. I tried adjusting the posi ...

Responsive Bootstrap tables nested within responsive tabs

Utilizing footable in conjunction with Boostrap Responsive Tabs leads to an issue post-resize. When the page is initially loaded on a desktop, everything functions properly until the screen is resized. Once the screen is resized, the tables within the tabs ...

Adjust the dimensions and position of the notification box using Twitter Bootstrap

I am struggling to center and adjust the size to 80% of an alert box, but the text-center class is not achieving this for me. <div class="text-center"> <div class="alert alert-info" style="width: 80%;" role="alert"> <i class="fa fa- ...

Angular causes the website to become unresponsive following certain animations

I am experiencing an issue with my Angular website where I have implemented an effect to show and hide photos on the homepage. The problem arises when after a certain period of time, the Chrome browser crashes and the website freezes. It seems like the con ...

Tips on fetching data from a different webpage via ajax

Hello, I am new to programming. I am looking for a way to update the content of the current PHP page with content from another PHP page using AJAX without needing to refresh the page. The content that needs to be replaced is located within div elements. ...

dividing Handlebars HTML content into different files or sections

I am looking to design a single route webpage, but I would like to divide the HTML code into multiple files. When rendering this particular route, my goal is for the rendered file to pull content from different template files and combine them into one coh ...

How can the spacing between Angular Material's mat-card-content and mat-card-actions be adjusted?

I am creating a mat card layout where there are two separate cards within the main card's content section. However, when I add a button for the actions section of the main card, there is no spacing between these two sections. How can I create a vertic ...

extract individual components from the google books api

It has been quite a while since I last dabbled in JavaScript, so I decided to embark on a project creating a "bookcase" to organize the books I have read and those I still want to read. One challenge I encountered was figuring out how to separate the eleme ...

How to integrate a toggle switch into an Angular datepicker component

Can the toggle switch be placed inside the calendar? I would like to have it positioned at the top of the open calendar so that users can choose to view date details using the toggle switch <form #uploadForm="ngForm" (keydown.enter)="$event.preventDe ...

step-by-step guide to disabling grayscale mode automatically

In recent times, a trend has emerged in Thailand where many websites are appearing in grayscale. This is achieved through the use of -webkit-filter: grayscale(100%), filter: grayscale(100%) and similar filters. Although it is possible to revert these webs ...

What could be causing the embedded dropdown to automatically select the initial option every time?

I am encountering an issue with a page that includes an html table rendered using node with express and ejs. The table contains a select dropdown in one of the cells, and it populates correctly with the right values. However, regardless of which option I ...

Leveraging Javascript within MVC3, either on a master page or child page

I'm currently developing a web application utilizing MVC3 and I am curious about the best practices for incorporating JavaScript. Specifically, I am uncertain about whether to include JavaScript in the master page as well as in individual child pages. ...

Ways to add gaps between flexbox items within a single row?

I have a coding dilemma where I am trying to display two items in the same row with a 12px gap between them, but my current method is not working as desired. I want there to be space between the A's and B's without resorting to traditional techni ...

What could be causing the dismiss button to not function properly on the bootstrap alert in my Flask application?

I have included jquery, the boostrap css link in the head, and the bootstrap javascript before the closing body tag. Additionally, I am utilizing Flask. {% for message in get_flashed_messages() %} <div class="alert alert-success alert-dismi ...

Issue with focus transition animation not functioning properly when unfocusing an HTML input field

Hey there! I'm currently working on styling a basic input, and I'm having trouble getting the unfocus animation to work properly. Can anyone help me figure out what's going wrong? I've tried commenting out the all: unset line and expl ...

What is the best way to customize the appearance of a form element within an angular-schema-form schema without affecting the overall

Currently, I am in the process of constructing a form using the incredible angular-schema-form. Creating the form schema object has been a success so far. My goal is to configure all the form components within the schema using the x-schema-form property in ...

Choose the option to retrieve information from the database

Within my database, there is a table named "train_information" which contains the following fields: train_id country_id user_id train_name tare_weight number_of_bogies number_of_axles wheel_diameter_min wheel_diameter_max In addition, I have developed t ...