Different option for animated side slider based on location

Whenever I click on this div, it slides out smoothly.

Check out these images to get a visual of what I am aiming for:

This is how the Div looks when collapsed by default https://i.stack.imgur.com/zJIsA.png

Once slid out, the Div looks like this (highlighted)

https://i.stack.imgur.com/sy78X.png

Notice what happens when the screen size changes. The clickable div ends up positioned behind other content which is something I want to avoid.
https://i.stack.imgur.com/ykvSU.png

This is the CSS for my Div:

.sliderDiv {
    z-index: -10;
    position: relative;
    left:  200px;
    width: 240px;   
}

I trigger the slide-out effect with this command:

slideItOut:function(){
            var divsize=$(".sliderDiv").offset().left-150;
            if(divsize>100){
                $(".sliderDiv").animate({
                    "left":"-=194px"
                },"slow");
            }
            else{
                $(".sliderDiv").animate({
                "left":"+=194px"
                },"slow");
            }
        }

The issue arises when the window is resized, as the responsiveness is lost and the div gets hidden behind other elements. Perhaps this method is not designed for responsive behavior.

Is there any way to make this sliding feature responsive or at least make sure it maintains its position when the screen size changes? I'm looking for a solution that allows the div to resize accordingly when the window is adjusted, similar to the first two images shown above.

Keep in mind that this implementation is within a modal, so the div is not fixed on the screen.

Answer №1

In order to solve the issue, your complete source code is necessary. Please provide the source code or a location where it can be accessed. I will then attempt to rectify the problem. Alternatively, I can propose an optimal solution.

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

Issues with Chrome causing Ajax synchronous requests to fail

Is the latest release of Chrome no longer supporting Synchronous Ajax calls? We're encountering an error with our Synchronous Ajax requests after updating to version 73.0.3683.103. Interestingly, Synchronous calls are still functioning properly on Fir ...

Enable users to provide ratings ranging from 0.5 up to 5

I recently created a rating component that allows users to rate on a scale from 0 to 4.5, with increments of 0.5, which is causing unexpected behavior. I actually want users to be able to rate from 0.5 to 5 instead. How can I achieve this adjustment? Below ...

Is it possible to incorporate an editable text feature within react-moveable? (Allowing for both dragging and editing capabilities)

In React Movable box, the text can be dragged with a left click and edited with a right click using the "contentEditable" attribute. However, on smartphones, editing seems to be disabled and only dragging is possible. <div className="move ...

Unusual dark streak beneath the Wordpress emblem

I recently created my website using Wordpress and decided to use a PNG image (140*82 px) as the logo instead of the default "site-title". However, I encountered an unusual issue where a black line appeared just below the image. After checking my "header.ph ...

Learn how to trigger a re-render in React to update a value stored in local storage

I need assistance in displaying a spinner with a percentage value during file uploads within my React application. To achieve this, I am utilizing Material UI's circular progress. My approach involves making a REST call using Axios to obtain the perce ...

How can HTML5 geolocation be utilized to provide real-time latitude and longitude coordinates for integration with the Google Maps API?

I am currently working on a project where I need to dynamically fetch longitude and latitude values from the browser geolocation and then include them in the options array for the Google Maps API. Here is the code snippet I am using: function initMap(){ ...

I am encountering an issue with identifying a directory in Node.js

This is my HTML code <div id="done_work_1" class="logo-slide-track"> </div> <script>$.ajax({ url: "/static/home/done/", success: function (data) { $(data).find("a").attr("href&q ...

Use a function to handle button click events rather than relying on the id

Hello everyone, I am a beginner and I have a question about using a function on two buttons with #ID. The problem is that I have to write the same function twice for different button IDs. I want to call the function with Onclick so that I only have to writ ...

distinguishing the container component from the presentational component within react native

I just started developing apps using React Native and implemented a basic login function with the view and login logic on the same page named HomeScreen.js. However, after reading some articles online, I learned that it's recommended to separate the l ...

Prevent border duplication in CSS and retain border visibility

Check out this fiddle where I have three divs with a border-width of 2px. Originally, the issue was that each div's border gets duplicated in between, resulting in a total border-width of 4px. To solve this, I applied a margin-top of -2px to each div, ...

What is the best way to manipulate and update individual counters in React components?

I developed a ticket ordering system for a project, but encountered an issue where increasing the quantity of one ticket also resulted in the incrementation of the other ticket's counter. I suspect this occurs because only one value is stored in the s ...

Utilize jQuery method in HTML to perform parsing operation

Is it possible to invoke my jQuery function from within my HTML code? Here is the code snippet: HTML section: <td style="text-align:left;" align="left" > <div id="bulletin-timestamp" > doTimeStamp(${bulletinTimeStamp[status.index ...

Incorporating TypeScript with jQuery for efficient AJAX operations

I recently added jQuery typings to my TypeScript project. I am able to type $.ajax(...) without encountering any compile errors in VS Code. However, when I test it on localhost, I receive an error stating that "$ is not defined." In an attempt to address t ...

When developing a node.js project using VMWare's shared folder, how can you manage the node_modules folder?

My current project needs to run on Linux, but I am using a Windows computer. This means I have to use a VM. Despite wanting to use WebStorm, I am avoiding JB Gateway due to its numerous bugs. My solution was to utilize the VMWare share folder function. Ho ...

Utilizing Angular Filter to compare the date in a JSON file with the current system date

<p id="appt_time" ng-if="x.dateTime | date: MM/dd/yyyy == {{todaysDate}}">DISPLAY IF TRUE{{todaysDate}} </p> Plunkr:https://plnkr.co/edit/r2qtcU3vaYIq04c5TVKG?p=preview x.dateTime | date: MM/dd/yyyy retrieves a date and time which results in ...

How can I utilize AJAX and PHP to upload an image?

I'm having an issue with uploading an image using PHP and AJAX. When I upload the image without AJAX, everything works perfectly. However, when I try to use AJAX to prevent the page from refreshing, the image/file doesn't get uploaded! Here is ...

Ways to set the className prop for all components automatically without having to specify it repeatedly

One challenge I face is dealing with code duplication whenever I create a new component. Is there a way to pass the className property between components without having to explicitly define it every time a new component is created? For example, when I cr ...

Obtaining Data from Fetch Response Instance

Currently, I am utilizing the fetch method to execute API requests. While everything is functioning as expected, I have encountered a challenge with one specific API call due to the fact that it returns a string instead of an object. Normally, the API pro ...

Discover the steps to dynamically alter the inclusion of the Bootstrap CSS file within an Angular project

I manage a multi-language website in both English (EN) and Arabic (AR). Currently, I am utilizing Bootstrap CSS from a CDN and adjusting the CDN link based on the selected language. index.html <!DOCTYPE html> <html lang="en"> <h ...

Responsive design issues with Bootstrap 3 box layout

I am currently working on creating a bootstrap4 layout that includes three boxes arranged side by side on a wide screen. However, my goal is to ensure that if the screen size decreases, the red and green boxes always stay adjacent to each other while the b ...