Tips for creating a sticky bootstrap column that remains in place as you scroll

I am looking to design a FAQ page similar to Twitter's FAQ. The goal is to have the left column remain fixed in its position while allowing users to scroll through the content.

Here is what I have attempted so far, but it is not functioning as expected.

    <template>
      <div>header here</div>
      <div class="container">
        <div class="row">
          <div class="col-lg-4">
            <div style="position: sticky;">
              1 of 2
            </div>
          </div>
          <div class="col-lg-8">
            2 of 2
          </div>
        </div>
      </div>
    </template>

Although suggestions from this source propose using the sticky property, it does not seem to be effective in my case.

Upon further consideration, I believe the issue may arise from both columns having equal height. As a result, applying the sticky property does not produce the desired effect. Is there a solution that would allow the column height to adjust based on content?

Are there any recommendations or solutions available? Thank you!!

Answer №1

The issue with the Sticky position not working on col-sm-4 is due to its parent class row having the display:flex property applied. If you modify

display:flex

to

display:block

then the Sticky property will function correctly, although it may alter your overall design.

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

Tips on designing checkboxes with CSS

Can someone help me figure out how to style a checkbox using the code below? <input type="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;" /> I've tried applying this style but it doesn't seem to work. The chec ...

Create a new variable and compile the sass/less file when it is requested

I'm exploring options to utilize Node.js or another server-side language to handle a specific type of request. For instance, receiving a request like this: The goal is to extract the value from the URL parameter and use it to dynamically update a var ...

WebpackError: The assignment of the property 'emulateTransitionEnd' to an undefined value cannot be completed

I've been attempting to implement Bootstrap in GatsbyJs, but it just seems to continually let me down. Is there a legitimate method to import Bootstrap without encountering the following error? WebpackError: Cannot set property 'emulateTransitio ...

Is there a way to navigate by scrolling, moving a centrally-positioned SVG along a path while also resizing the SVG?

After following the instructions in this post about resizing SVGs, I managed to keep the red square on the path while resizing the SVG. However, a new issue arises when scrolling down - the red square is not moving to stay positioned at the center of the w ...

When the horizontal scroll is turned off, it also disables the functionality of my mobile-friendly

I came across a helpful post on StackOverflow that suggested using the following code to disable horizontal scrolling: html, body { overflow-x: hidden; } This solution did resolve my issue of horizontal scrolling, but unfortunately it caused problems ...

Working with mutations in Vue.js by utilizing mapMutations

Hi there, I am relatively new to Vue.js and have a question about the mapMutation method. I am trying to figure out how to pass parameters using this method. My goal is to streamline my code by transforming two methods using mapMutations: increment() { ...

Unable to position divs next to each other in Firefox, yet successfully achieved in Chrome

I have successfully placed two divs side by side using the following markup, as shown in image 1, but this layout only works on Chrome. However, Firefox renders it differently as seen in Image 2. Is this a known issue that I overlooked? How can I resolve t ...

Create a component by dynamically generating HTML content and initializing it

I'm currently working on a Laravel application using VueJS with gulp and browserify. Everything seems to be functioning properly with my vue components when integrated with normal HTML or blade files. The issue arises when attempting to load the HTM ...

What is the best way to embed a section of another website within an iframe and seamlessly guide a user to complete a purchase using a shopping cart?

Seeking advice on how to improve the functionality of my website. Currently, the domain I'm focusing on serves as a landing page, redirecting users to another site for purchases. I've built a separate website for this domain in order to establis ...

Page design ruined as a result of oversized fonts in IE9 for <h2> elements

Everything looks great on various browsers, except for the notorious IE9. We've implemented a block-style layout with a width of 660px, centered on the page. Despite setting the h2 width to 660px to match the layout, IE9 displays the font size much ...

Create a customized HTML popup featuring various packages

I am struggling to create an HTML popup within a React component due to some errors Here is the code snippet: <div> <button class="toggle">Button</button> <div id="link-box"> <ul> ...

Obtaining the href content from a specific class using Selenium

I am attempting to extract information from a webpage that contains the following HTML: <div class="someclass"> <p class="name"><a href="#/word/1/">helloworld</a></p> </div> My objective is to retr ...

Each time I attempt to alter the color based on the count, an error is thrown: "TypeError: Cannot read property 'style' of null"

If the count is equal to zero, I want to change the color to black in the code below: if(Count === 0){ document.getElementById('value').style.color = 'black'; } return( <div className='container_new'> < ...

Expanding a Material UI Accordion does not cause the surrounding content to shift or move

I'm currently designing a User Interface for a web application that allows users to have multiple projects open simultaneously. To achieve this, I decided to use an accordion as the logical component in the left navigation bar. The reason behind this ...

Is there a way to retrieve the widths of several <span> elements at once?

Having a few <span> elements generated dynamically, I need to find out their combined width. Wrapping them in a <div> and using alert($("#spanWrap").width()); resulted in the container's width instead of that of the <span> elements. ...

Changing the appearance of a website by switching CSS stylesheets according to the size of the browser

Trying to build two versions of my website: one for mobile devices or small browsing windows, and another for large browser windows. Looking to link HTML to different style sheets based on browser size. Current attempt in code only addresses total screen ...

The MVC 5 view is unable to display an HTML image when adding it within an appended div

Currently, I am working with ASP.net MVC5 at a novice level. I'm faced with the challenge of creating a div that displays an image using a JavaScript function. Here is the code snippet I have: function showLoadingImage() { $('#submit_Em ...

Creating a visible block in ReactJS: Step-by-step guide

Hello and thank you for all the hard work you do on this platform. I am relatively new to working with ReactJS and have been encountering some difficulties trying to integrate it with sandbox environments like JSFiddle. I have a div element named "app-con ...

How can you use Vue.js with NW.js to seamlessly open a link in the user's preferred browser?

Essentially, the question lies within the title itself, but allow me to elaborate. I have a proposed solution for this issue, however, I believe it lacks practicality and I am seeking a more efficient approach. For instance, opening one link is not a prob ...

What is the process for setting up a header in a v-data-table?

Can someone help me understand how to style a Vuetify table or create a custom one similar to this design? I have tried using plain table tags, but I am struggling with applying styles in Vuetify. I would like to build a table that looks like the one bel ...