What could be causing the 'position: sticky' feature to fail when using Core UI's Bootstrap CSS?

I am currently in the process of constructing a react dashboard using Core UI's react template, which can be accessed here.

CSS

.top-stick {
    position: sticky !important;
    position: -webkit-sticky;
    top: 5rem;
    overflow-y: auto;
    height: calc(100vh - 5rem);
}

JSX

<div className="animated fadeIn">
  <Row className="app-scrollable-body">
    <Col xs="12" sm="4" md="3" className="top-stick">
      <Card className="toic">
        <CardBody>
          Lorem ipsum dolor sit amet
        </CardBody>
      </Card>
    </Col>
    <Col xs="12" sm="8" md="9">
      <Card>
        <CardHeader>Card title</CardHeader>
        <CardBody>
        Lorem ipsum dolor sit amet
        </CardBody>
      </Card>
    </Col>
  </Row>
  <div className="app-fixed-footer">
    <span>
      <a href="https://coreui.io">CoreUI</a> &copy; 2018
      creativeLabs.
    </span>
    <span className="ml-auto">
      Powered by{" "}
      <a href="https://coreui.io/react">CoreUI for React</a>
    </span>
  </div>
</div>

However, I have encountered an issue where the card does not stay sticky upon scrolling.

After checking the styles in the CSS, it appears to be correct. Additionally, there is no overflow: hidden in the CSS Tree.

https://i.sstatic.net/2iQA2.png

Answer №1

The main issue arises from the presence of overflow within the .app-body element. This situation is a bit complex, but it's crucial to ensure that no element between the scrollable element and the sticky element has an overflow property set.

To better demonstrate this concept, consider the following example. The scrolling occurs in the viewport, while the wrapper contains overflow:hidden or even

auto</code), resulting in the sticky behavior not functioning as intended.</p>

<p><div>
<div>
<pre class="snippet-code-css lang-css"><code>.container {
  display:flex;
  align-items:flex-start;
  border:2px solid green;
}
.content {
  flex:1;
  height:200vh;
  background:red;
  margin:10px;
}
.sticky {
  flex:1;
  height:100px;
  background:blue;
  margin:10px;
  position:sticky;
  top:0;
}

.wrapper {
  overflow:hidden;
  border:2px solid red;
}
<div class="wrapper">
  <div class="container">
    <div class="sticky"></div>
    <div class="content"></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

Determine if offcanvas element is visible upon initialization in Bootstrap 5 Offcanvas

I have a search-filter offcanvas div for location and property type on this webpage: On larger screens (desktop), the offcanvas is always visible, but on smaller screens (mobile), it is hidden and can be toggled with a button. This functionality works per ...

Creating a sleek animation with JQuery for a dynamic-width div

Here is a snippet from my latest project. Take a look at the demonstrationFIDDLE. In this project, I have created a list with buttons: <a href="#f1" class="bt">1 <div class="show">Computers Networking</div> </a> When you ...

What is the process for including echo HTML field in the WooCommerce order view?

I have successfully added HTML input fields within functions.php. However, these echoed fields are not displaying in WooCommerce orders after placing an order. I am looking for a way to include the values and labels of these fields in the orders view wit ...

Can a sophisticated text editor be utilized without a content management system?

Many website builders utilize rich text editors as plugins to enhance content creation, such as in CMS platforms like Joomla and WordPress. However, can these same editors be easily integrated into a custom website built from scratch using just HTML, PHP ...

Pull in content or data from a separate page by leveraging AJAX

Hello, I'm just starting out in programming and I could really use some help with this issue. index.html <button id="press">Click here</button> <div id="show_image"> </div> <br> <div id="appended_area"></div&g ...

Centering a floating div in IE causes issues

Suppose I have the following HTML: <div id="submitPage" align="center"> <div id="middlecontainer"> <p align="center" id="loading-image">&nbsp;<img src="/cso/images/loading.gif" border="0"> <font colo ...

Creating a custom Jquery function to generate a Div element instead of a Textbox in your web application

I need assistance with a jquery function that retrieves data from a JSON PHP MySQL setup. The retrieved results are currently displayed in textboxes. function showData(wine) { $('#Id').val(wine.id); $('#question').val(wine.question ...

I want to create a form with two dropdown menus placed side by side within a parent DIV, and I want them to collectively occupy the entire width using Bootstrap

Currently, I am working on a search form using Bootstrap. Everything is going well, but I am facing an issue where two multi-option elements need to be placed side by side and together occupy 100% of the width within their containing DIV. Just for clarity ...

Taking data input from three textboxes and storing them in a PHP array

In my HTML form, I have 3 text input fields and one submit button. Each text field is intended for entering the name of an animal, which should then be saved into a PHP array. Here is the structure of my HTML form: <form action="Test.php" method="post ...

Concealed Button in Javascript

I've got a JavaScript function that effectively hides a link or button for a specific period of time. JavaScript: <script type="text/javascript"> function showNextButton() { document.getElementById("nextbutton").style.visibility = " ...

An alternative to Beautiful Soup for Python 3.2

Looking to create a web crawler for extracting information from various web pages, I discovered Beautiful Soup which seemed like an excellent tool. It allows me to parse entire documents, create dom objects, iterate through them, and extract attributes sim ...

Eliminate border-radius property from Bootstrap 4 breadcrumb using Sass styling

Within Bootstrap 4, there exists a Sass variable known as $enable-rounded which "Enables predefined border-radius styles on various components." (https://getbootstrap.com/docs/4.1/getting-started/theming/#sass-options) I need to eliminate the rounded ...

Uploading a File to a Remote WCF Service via jQuery AJAX on Different Domains

I am currently facing some difficulties in achieving the following task and would really appreciate any guidance you can provide. My goal is to upload a file from my HTML5 site to a cross domain WCF service hosted in IIS 7.5. Additionally, I need to send ...

When the app is started before turning on Cordova geolocation, the geolocation feature fails to work

In my Cordova app, I am experiencing location issues on Android while it works perfectly fine on iOS. Here's what's happening: When the app starts up, it requires a location check, and if the location is turned off, a warning message with a retr ...

Display an icon button when a user edits the text in a text field, and make it disappear once clicked on

Figuring out how to incorporate a v-text-area with an added button (icon) that only appears when the text within the text area is edited, and disappears once it is clicked on, has proven to be quite challenging. Below is a simplified version of my code to ...

What is the reason that adding bottom padding and margins is ineffective in creating vertical space between these links?

I am struggling with aligning links vertically in a div. Currently, I am using <br> tags to stack them on top of each other because I couldn't find a way to add vertical spacing with CSS. I attempted to add bottom margin and padding to the &apos ...

Tips for enabling only a single div to expand when the "read more" button is clicked

I'm having trouble with my blog-style page where I want only one "read more" link to expand while collapsing the others. I've tried various jQuery methods and HTML structures, but haven't been able to achieve the desired result. Can someone ...

What steps are involved in incorporating dynamic pagination in PHP using this particular snippet of code?

I am looking for a way to display a list of numbers from 1 to 1000 in a single line with the ability to scroll. However, I need to exclude both "Prev" and "1" from this list. How can I achieve this? Below is the code snippet that I currently have: echo ...

When resizing the window, the width change in JQuery always resets to 0

I've been trying to adjust the width of a div element when the window is resized, but for some reason, the width always ends up being 0 after the resize event. function resizeUploadField() { var uploadInputField = $('.input-append&apo ...

"Create a unique visual layout with CSS using a four-grid

When utilizing four div grids and increasing the content size of table 2, it causes table 3 to align with table 4, creating a large gap between tables 1 and 3. Is there a way to adjust the responsive content sizing for tables 1, 3, 5... and 2, 4, 6... in o ...