Efficiently adjusting the height of a sticky sidebar

I am currently implementing a Bootstrap grid with two divs in a row. I need my reply-container to be fixed (sticky). However, when setting position: fixed; it is affecting the element's width by adding some additional width. With position: sticky, setting height: 100%; results in the sticky behavior working well but the element does not reach full height. On the other hand, setting min-height allows the element to be full height but it loses its sticky functionality. How can I achieve a sticky div with full height?

<template>
  <div class="container-full">
    <div class="row">
      <div class="col-8">
        <div class="tweets-container">
          <div
            v-for="tweet in tweets"
            :key="tweet.id"
          >
          </div>
        </div>
      </div>
      <div class="reply-container col-4">
        <h1>Replies</h1>
      </div>
    </div>
  </div>
</template>

<style scoped>
.tweets-container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.tweet-card {
  background: #fff;
  border-radius: 5px;
  padding: 3px 6px;
  min-height: 125px;
  border: 1px solid #6e6b7b;
}

.reply-container {
  background: #fff;
  position: sticky;
  right: 0;
  top: 0;
  height: 100%;
  /*min-height: 100%;*/
}
</style>

Answer №1

Shortly after my initial post, I found the solution by using height: 100vh; instead of height: 100%;

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

The issue of CSS not functioning properly across various page sizes

I have created my toolbar: <header className='toolbar'> <nav className='toolbar_navigation'> ///hamburger: <SideDrawer drawerClicked = {props.drawerClicked} /> ///LOGO ...

Issue with Laravel breadcrumbs not selecting the correct view

I'm currently utilizing the Laravel Breadcrumbs package from here: https://github.com/davejamesmiller/laravel-breadcrumbs Following all the provided instructions, I have successfully generated breadcrumbs. However, it seems that the package is not re ...

Picture inside text area covering drop-down list

After making some adjustments to Bootstrap using a custom -theme.css file, I successfully altered the appearance of the dropdown menu. By removing the borders from the navbar and wrapping a header around it set to be fixed on top, everything seemed to be w ...

Prevent a specific image from being impacted by CSS styling

I've implemented the following CSS on my website for image opacity: img { opacity:0.4; filter:alpha(opacity=40); } img:hover { opacity:1; filter:alpha(opacity=100); } Now, I am looking to exclude certain images from being affected by this ...

I possess three stylish CSS buttons, however, the other one is accompanied by <br />

I'm struggling to ensure that the three CSS buttons are the same size (using padding) and vertically aligned, as the second button includes a "<br />" which throws off the alignment. I was advised to use flexbox, but I haven't been able to ...

react elements are consistently positioned at the bottom of the webpage

I am currently in the process of developing an airline reservation system using the MERN stack. I have successfully implemented the navbar, however, whenever I try to add a new div or element, it appears outside of the page and requires additional styling ...

The burger icon in the navigation bar is malfunctioning, showing just a single horizontal line instead

I've been working on creating a responsive layout button that resembles the following design: https://i.sstatic.net/v5vDd.png However, I've encountered an issue where I can't seem to generate all three horizontal lines, only one of them. T ...

How can I make the footer on my webpage have a white background?

My goal is to create a white div that spans from point (A) to point (B) on the page, just like in the image. I aim for it to stretch all the way down to cover the entire browser without showing any gray background underneath, even when the page is scrolled ...

What is the best way to display my menu bar when the icon is hovered over?

I want to create a menu bar similar to the one found on . I am unsure of how they achieved this effect, but it seems to involve a scroll-over action. However, when I attempt to replicate it, the words still appear even when the menu bar is collapsed. < ...

Issues observed when implementing replaceWith() to replace text tags with input field on a web page

Just a simple EDIT request. I want to modify the headers so that when I click on the "edit" icon, the header will change to a text field and the "edit" icon will switch to a "save" icon. $('#editheader').click(function(e){ va ...

To close the menu, simply tap on anywhere on the screen

Is there a way to modify a script so that it closes the menu when clicking on any part of the screen, not just on an 'li' element? $(function() { $('.drop-down-input').click(function() { $('.drop-down-input.selected').rem ...

Ways to stop a tag from causing disruption to the alignment of another

In a div with text-align: center; applied, I have two tags. My issue is that I want one of them to be centered on the same line, while the other is positioned to the right. However, both tags are currently sharing the centered space and extending equally t ...

Troubles arise with IE8 when using Position: fixed styling

Here is the CSS code I am using: background-color: White; border: 2px solid black; padding: 10px; position: fixed; right: 5px; top: 0; width: 250px; While this code works well in Chrome, Firefox, and Safari, I am facing issues with IE8. The position of t ...

Image superimposed with vertical dimension

I have a photo with specific dimensions and I want to create a div box with a button inside the image, similar to what is shown in this example: Example Image Here is my current code attempt: .wrapper { width: auto; text-align: center; } .wrapper: ...

Title with lower border shorter than width

Looking to achieve an underline effect with a bottom border that is narrower than the width of the h2 title. Though I typically avoid uploading images, here is one to provide further clarification of my question: ...

Tips on adding CSS to a React component

I've successfully converted an HTML file into a component designed to resemble a 7-segment LED display. I have imported the necessary CSS styles from the index.css file, but I am unsure how to properly apply these styles within the component. My atte ...

Tips on incorporating several class names into Next.js elements

My current challenge involves an unordered list element with the following structure: <ul className={styles["projects-pd-subdetails-list"]}> {detail.subdetails.map((sub) => ( <li className={styles[ ...

Positioning the footer to sit at the bottom of my webpage, leaving a pleasing margin at the top

One technique I frequently use to ensure my footer stays at the bottom of my page is by utilizing an empty div. Here's how the code looks: <body> <div id="canevas"> <article>My website's content</article> ...

Tips for aligning text in MUI Breadcrumbs

I am currently utilizing MUI Breadcrumb within my code and I am seeking a solution to center the content within the Breadcrumb. Below is the code snippet that I have attempted: https://i.stack.imgur.com/7zb1H.png <BreadcrumbStyle style={{marginTop:30}} ...

Error message: "The property or method you are trying to access is not defined

I had no issues with my app until I added the JavaScript, now I'm getting constant errors in the console. One of the errors I see is: Property or method "show" is not defined on the instance but referenced during render. Make sure that this proper ...