Cards in Bootstrap 4 not adhering to sticky positioning as an alternative to affix

I have created a webpage for my thymeleaf-based Spring Boot project with various cards. Here is the code snippet:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Card</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body> 
 
<div class="container-fluid">
  <h2>Cards Columns</h2>
  <div class="body-content" id="mainBody">
  
  <div class="row">
                <div class="col-sm-3 mb-3 mb-md-0 fixed-bottom sticky-top" style="padding-left: 50px;padding-right: 20px;padding-top: 10px;padding-bottom: 50px;">
                    ...
                </div>
                <div class="col-sm-9" style="padding-left: 20px;padding-right: 100px;padding-top:10px;padding-bottom: 50px;">
                    ...
                </div>
            </div>
  
  </div>
  </div>
</div>

</body>
</html>

Currently, I am trying to make the Document Summary card sticky on scroll so that its values are always visible.

I attempted using classes like `sticky-top` and `sticky-bottom`, along with modifying the CSS as shown below:

   .make-me-sticky {
      position: sticky;
      top: 0;
     }

Previously, it worked fine with the `affix` class, but after upgrading to Bootstrap 4, I encountered issues making it work. It seems to be incompatible with the card element or there might be something I am missing.

I am looking for a CSS solution rather than resorting to JavaScript to achieve this functionality.

Answer №1

By utilizing the div with col class, I was successful in resolving the issue of overlapping.

     <div class="row">
     <div class="col">
     <div class="col-sm-3 col-lg-3  mb-3 mb-md-0 fixed-top sticky-top pt-5" 
     style="position: fixed;">Additional code will go here</div>
     <div class="col-sm-9 col-lg-9 " style="margin-left: 330px;padding- 
     top:10px;padding-bottom: 50px;">More code goes here</div>
     </div></div>

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

Having trouble with CSS font imports not functioning as expected

Apologies in advance for the repeated inquiries, but despite my efforts, I cannot seem to find a solution. I am attempting to utilize a downloaded font that I've placed in a "fonts" directory. This folder resides alongside all of my webpages. The sp ...

How can I create a reverse animation using CSS?

Is there a way to reverse the animation of the circular notification in the code provided? I want the circle to move forward, covering up the info and fading out. I've tried switching the animation around but haven't had success. Any suggestions? ...

What strategies can be implemented to decrease the value of the writing box by 2.5%?

I would like to decrease the value in the input box by 2.5%. Here is the HTML code snippet: <div class="ZakatCalc"> <div class="calcimg"> <img src="" alt="" srcset="" class=" ...

Exploring the Power of Laravel 5 with AJAX

When selecting a client name, I would like to use ajax to display a partial form. Currently, I am able to retrieve data from the database with this script: <script> $('#client').change(function(){ var client = $(this).val(); var ...

Is your webpage slow to respond after a page-refresh? (Delayed HTML rendering causing lag)

Whenever I adjust the screen size to that of a phone or any device smaller than 768px, the search bar doesn't display in its proper position until the page is refreshed. It should be correctly placed right from the start. Furthermore, when I resize th ...

Optimize Material-UI input fields to occupy the entire toolbar

I'm having trouble getting the material-ui app bar example to work as I want. I've created a CodeSandbox example based on the Material-UI website. My Goal: My goal is to make the search field expand fully to the right side of the app bar, regar ...

Issues with Bootstrap container causing overflow and lack of responsiveness (resulting in consistent display of two columns)

I'm facing an issue with a form layout I created that has two columns. Even when the browser width is decreased and the content overflows, the two columns remain the same. I've attempted modifying the code by using plain DIV with the container cl ...

Press the HTML link to interact with a text using JAVA

I am currently working on creating a class that is able to interact with an A text/button in HTML. The webpage requires a username and password, so I have utilized JSOUP to parse the document and insert the user and password details using the .data method: ...

Is there a way to isolate the highlighted text from an HTML document?

I am in search of a solution to extract all the bold snippets within the content of an HTML document. The task needs to be performed on the server side using Java, rather than on the client-side browser. The text appearing as bold on the page may be due t ...

Can you target an 'input' field that is within a component conditionally rendered using 'v-if'?

Imagine this vue.js template code: <div v-if="y===0"> <input ref="textbox">{{textbox}}</input> </div> In the scenario where y is data retrieved asynchronously, Is there a way to direct focus to the 'input' element onc ...

Issue with triggering onchange action for Multiple File Upload functionality

I'm currently in the process of developing a Website that requires a feature allowing users to upload multiple files. Here is the input-field I am working with: <div class="carousel-item carousel-custom-item active input-wrapper" > <inpu ...

Creating a dynamic side navigation similar to Gmail using Bootstrap 5

Is there a way to achieve a Gmail-style side menu in a Blazor Server application (using .NET 6 Blazor Server) where only icons are initially displayed, and hovering over the menu expands it to show names without reducing the main body section width? Below ...

Regular expressions can be used to extract specific attributes and inner content from a div element within a contentEditable container

Context I am currently developing a tagging system called @Name for my website. Successfully, I have managed to detect names upon keystroke and replace the content with the corresponding div class='tag' data-id='User-id'>Name</di ...

The debate between utilizing CDN or installing a library through NPM

My journey with NPM has just begun, and I am struggling to grasp how the files within node_modules get integrated into my index.html. Scenario 1: CDN Take jQuery, for instance. When using a CDN, it's as simple as adding the CDN link to a <script& ...

Preventing access to websites through a web application using JavaScript

I am in the process of creating a web application that enables users to create a list of websites they wish to block, preventing access from their browsers. My goal is to block websites on all browsers, but I have narrowed my focus to Chrome for now. I ha ...

Using a PHP variable as the input for the img src attribute in HTML

I am currently working on a project that involves creating a gallery to showcase all the .jpg files from a specific local directory. However, I seem to be encountering some issues with it. <?php $directory = "img/"; $images = glob ...

Add a border around the div that runs into the header

I am looking to create a border and header similar to this example: [![][1]][1] Is there a CSS solution for achieving this design? One method I have tried that seems to work is: .header{ margin-top:-10px; background:#fff; } Are there any alternate opti ...

Hide the navigation bar elements specifically on Safari browser when using Bootstrap v4.5.3

I'm having an issue with my Bootstrap v4.5.3 navbar not displaying correctly on Safari browser. All I see is the colored line, no text or hamburger icon. Can anyone help me with this? Here is my Navbar Code: <nav class="navbar navbar-expand-l ...

A method for determining the quantity of <li> elements within a <ul> container while applying specific conditions

I am currently using document.querySelectorAll('ul > li').length to count the total number of items in my list. However, I am wondering if there is a way to count only those items that meet a specific condition. For example: <ul> < ...

Adjusting the properties of a <span> tag when hovering over a different element

Query: I am trying to dynamically change the color of the span element with classes glyphicon and glyphicon-play when the user hovers over the entire element. How can I achieve this? Recommendation: .whole:hover > span.glyphicon.glyphicon-play { c ...