Issue with maintaining fixed positioning of css elements while scrolling

I'm currently working on a school project and I seem to be encountering an issue with the positioning of the slider I created. Specifically, I am having trouble getting the bottom fixed position for it. The problem arises when scrolling the page, as the slider also moves along with it even after applying position:fixed in the CSS. (I hope I have explained the problem clearly) Any help or guidance on this matter would be greatly appreciated!

.carousel-container {
  padding-top: 6%;
  margin: auto;
  overflow: hidden;
  height: 720px;
  width: 1080px;
  transform: none;
}

.carousel-slide {
  display: flex;
  width: 100%;
  height: 720px;
}

#prevButton {
  position: fixed;
  top: 50%;
  z-index: 10;
  left: 10%;
  cursor: pointer;
}

#nextButton {
  position: fixed;
  top: 50%;
  z-index: 10;
  right: 10%;
  cursor: pointer;
}
<div class="Galleria">
  <div class="carousel-container">
    <div class="carousel-slide">
      <img class="galleria" src="thumb-1920-672647.jpg" id="lastclone">
      <img class="galleria" src="thumb-1920-672645.jpg">
      <img class="galleria" src="thumb-1920-672643.jpg">
      <img class="galleria" src="thumb-1920-672648.jpg">
      <img class="galleria" src="thumb-1920-672647.jpg">
      <img class="galleria" src="thumb-1920-672645.jpg" id="firstclone">
    </div>
    <input id="nextButton" type="image" name="Name of image button" src="Icone\SliderNext.svg" alt="PrevButton">
    <input id="prevButton" type="image" name="Name of image button" src="Icone\SliderPrevious.svg" alt="NextButton">
  </div>
  <hr style="width:50%; position:relative; margin:auto; margin-top:5%;  border-color:#000000;">
</div>

Answer №1

Individuals scroll within the container because specific height and width are provided, causing the container to become fixed when the height exceeds 750px. The Galleria div acts as a container for all elements inside, creating a card-like structure with fixed elements. Here is an example of how you can achieve this:

      .Galleria{
       width:100vw;
       height:100vh;
       position:relative;

       .carousel-container{
        padding-top: 6%;
        margin:auto;
        overflow: hidden;
        height:720px;
        width:1080px;
        transform: none;
       position:fixed;
    }
    .carousel-slide{
    
        display:flex;
        width: 100%;
        height:720px;
    }

    #prevButton{
        position:fixed;
        top:50%;
        z-index:10;
        left:10%;
        cursor:pointer;
    }

    #nextButton{
        position:fixed;
        top:50%;
        z-index:10;
        right:10%;
        cursor:pointer;
    }
    <div class="Galleria">
        <div class="carousel-container">
          <div class="carousel-slide">
            <img class="galleria"  src="thumb-1920-672647.jpg" id="lastclone">
            <img class="galleria" src="thumb-1920-672645.jpg">
            <img class="galleria" src="thumb-1920-672643.jpg">
            <img class="galleria" src="thumb-1920-672648.jpg">
            <img class="galleria"  src="thumb-1920-672647.jpg">
            <img class="galleria" src="thumb-1920-672645.jpg" id="firstclone">
          </div>
            <input id="nextButton" type="image" name="Name of image button" src="Icone\SliderNext.svg"  
            alt="PrevButton">
            <input id="prevButton" type="image" name="Name of image button" src="Icone\SliderPrevious.svg"  
            alt="NextButton">
        </div>
       <hr style="width:50%; position:relative; margin:auto; margin-top:5%;  border-color:#000000;">
    </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

What are some ways to streamline inline styling without having to create numerous variables?

Currently, I am in the process of constructing a tab component and establishing inline variables for CSS styling. This particular project involves a streamlit app that allows me to modify settings on the Python side. At the moment, there are four elements ...

ngx-datatable detail row failing to expand properly

I am striving to develop an ngx-datatable component that can be utilized universally for consistent styling and functionality. Although most features are working correctly, I'm struggling to understand why the details row isn't expanding as expe ...

What causes CSS animations to suddenly halt?

Recently, I've been delving into the world of CSS animations and experimenting with some examples. Below is a snippet of code where two event handlers are set up for elements, both manipulating the animation property of the same element. Initially, th ...

Clickability issue with searchbar results caused by onBlur event

My searchbar functionality includes showing results in a dropdown list when the user searches. However, I am facing an issue with the onBlur event that changes the display of the list to none when the user clicks away from the search box. The problem aris ...

The background-size property fails to function properly on mobile devices

It's really puzzling why this issue is happening, perhaps it's due to my fatigue. The problem lies in the fact that the "background-size" property isn't functioning on my mobile devices; however, it works perfectly when I try to simulate it ...

Restricting Checkbox Choices with JavaScript by Leveraging the forEach Function

I am developing a checklist application that limits the user to selecting a maximum of three checkboxes. I have implemented a function to prevent users from checking more than three boxes, but it is not working as expected. The function detects when an ite ...

How to retrieve a DOM element using Aurelia framework

When it comes to accessing a DOM element in Aurelia, what are the best practices to follow for different use cases? Currently, I have two scenarios in my Aurelia project: Firstly, within the template, there is a form that I need to access from the view-mo ...

What impact does Bootstrap .ratio have in making the img show up over the offcanvas menu?

Is there a way to prevent a ratioed image from appearing above the offcanvas menu? When using Bootstrap 5 and specifying a 16x9 ratio for the image... <div class="ratio ratio-16x9 my-3"> <img width="768" height=&q ...

Creating a Modal Dialog with Justified Tab and Dropdown Using Bootstrap 4.1

I am struggling with Bootstrap 4.1 as I try to align content to the right side. Specifically, I have a Navigation Bar that triggers a Modal Dialog containing Tabs. The dropdown menu on the far right of the Tab is what I want to justify to the right. Here a ...

I find myself unable to write any code using my Visual Studio Code

I'm facing an issue where I can't write any code on my Visual Studio Code. Despite following all the recommendations on the official website, I haven't been able to resolve the problem. More information here Here are the changes I have tri ...

Continuously refreshing the content

Having an issue with the $.ajax() function while trying to load content into a DIV from another page. The content keeps reloading into the element continuously. Observing my debugger, it seems that the element .driving_action_body is constantly reloading ...

Tips for aligning pagination block at the center using react-bootstrap

Currently, I have implemented a custom pagination system for a small web application that I am developing using react-bootstrap. I have successfully integrated and set up the pagination functionality. As someone who is still new to react and bootstrap, wit ...

Updating the input value of one field by typing into another field is not functioning properly when trying to do so for

I'm managing a website with a form that has three fields which can be duplicated on click. Here is an excerpt of my code: $(document).ready(function() { var max_fields = 10; var wrapper = $(".container1"); var add_button = $("#niy"); var ...

Steps to customize a CSS file within node_modules

Is there a way to make changes to a CSS file in the "node_modules" dependency without them being overwritten when I run npm install? I want to keep the modifications I've made to the node module files. ...

Is the ID "nodeName" specifically designated as reserved in the HTML5 language specifications?

I have an element with the following id: <span id="nodeName"></span> In my HTML code. Then, when using jQuery to do the following: $("#nodeName").html("someString"); I am getting an error in the console that says: Uncaught TypeError: Objec ...

Achieve equal height columns when they are stacked vertically using Bootstrap 5

Can columns be equal height when they become rows on mobile devices? <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="57353838232423253627176279677965">[email protected]</ ...

"Master the art of creating a curved circular arrow using a combination of HTML, SVG, D3.js

I am looking to design an SVG circle with a fading stroke that blends into the background and features an arrow at one end. The goal is for the ring to fade out completely right above the arrow, similar to the visual reference provided in the image.view ex ...

Obtain the dropdown menu links for every row in a table using Python3 along with Selenium

Seeking assistance as a beginner in Python, I am attempting to automate the downloading process of old newspaper archives from a specific website () using the script provided below. Despite my efforts, I have encountered difficulty in getting the script t ...

Assign the filename to the corresponding label upon file upload

I've customized my file uploader input field by hiding it and using a styled label as the clickable element for uploading files. You can check out the implementation on this jsFiddle. To update the label text with the actual filename once a file is s ...

Guide to Saving a List in Local Storage

I have successfully created a CRUD page where users can input text and it gets added to a list. Now, I am trying to save that list in localStorage but encountering an issue where the console log is showing an empty object. Any assistance on this matter wou ...