Tips for creating a responsive layout with a background image and jQuery animations

I have been working on a website that includes various background images. However, I have encountered an issue with the mobile version where not all backgrounds are displayed correctly on devices. Additionally, I have implemented jQuery animations for desktop versions using margin-left to margin-top animation. My concern now is how to get these jQuery animations to work on mobile devices. Here is my CSS for the background image:

.home
{
background-image:url("../img/sofa.jpg");
background-size:100% 100%;
background-repeat:no-repeat; 
height:100vh;
width:100%;
top:0;
left:0;
}

And this is the jQuery code for the animation:

$(document).ready(function(){ 
   setInterval(function(){  
$("#animate1").fadeIn('slow')
.animate({'margin-left':'220px','margin-bottom':'20px'},2000,
function(){         $('.1st').animate({'opacity':'0'},1000,
function()    {$('.1st').animate({'opacity':'1'})})
   }).fadeOut();

   $("#animate1").fadeIn('slow')
.animate({'margin-bottom':'0px','margin-left':'-140px'},2000).fadeOut();

  },2000);
    });

I need assistance on making this jQuery animation compatible with mobile versions since it involves margin type animation. Thank you in advance for your help!

Answer №1

If you want to create a background image slideshow, consider incorporating jQuery and CSS3 media queries for optimal responsiveness.

@media screen {max-device:320px} @media screen{max-device:600px}

These techniques will allow you to effectively manage your breakpoints.

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 for converting response text into HTML code

I am receiving a text response like this <span class='text-4xl'>description1</span> When I display it on the screen: import React,{useContext, useEffect} from 'react'; import blogsContext from '../context/blogsCon ...

Creating a zebra-striped list using CSS can be done by styling even and odd list items differently

I am facing an issue with Angularjs and the table tag when using group loops. The problem arises in achieving correct zebra striping for the list. How can I solve this to ensure the zebra pattern is applied correctly? <table> <tbody> <tr ...

Freezing browser during an active AJAX call

I am currently working on an ASP.NET Web App and have noticed a peculiar issue. Whenever I make a simple ajax call (as shown below), the web application becomes unresponsive to any actions I try to perform on a different browser. $.ajax({ type: "G ...

Can mouseenter and mouseleave events be implemented in Chart.js?

Currently, I am using the onHover function on each pie to implement some scale/zoom effect. However, I would like to switch to using mouseenter and mouseleave. When there is a mouseenter event on a pie, it should enlarge with scale/zoom effect, and when th ...

Exploring jQuery: Techniques for Hovering, Changing, and Toggling Images

Currently, I am busy working on my project and I am attempting to achieve this by... I ideally want everything to be operational through click actions for each individual image, allowing them to have their unique "paper". I am aiming for a hover effect an ...

Troubleshoot: Bootstrap Table Alignment Problem

I've been struggling to align my table header and content properly, as shown in the image. I want the header aligned to the right while keeping the rest of the content aligned to the left of the header. Is there a way to achieve this using only CSS wi ...

Is there a way to shift the display of inline-block to the right?

I'm struggling with positioning a div that's nested within a display:inline-block. How can I align it to the right side of the container? <div style='width:100%'> left <div style='display:inline-block;position:relative;r ...

Showcase a picture within a row of a table using Ajax in an MVC framework

Getting straight to the point, I have a similar code snippet in my Controller: return base.File(getSomeImageBitmap, "image/jpeg"); This code successfully displays the image in a new window using @Html.ActionLink. However, I want the image to be directly ...

The alignment of image and text next to each other is not functioning as intended

I've been attempting to display an image and text next to each other, but I'm encountering some issues. The current output looks like the figure below: https://i.stack.imgur.com/WxxrS.jpg The desired layout is as shown in the following link: ht ...

How to change the tabIndex of an input element dynamically

In the Angular application I have developed, there is a form where users can input multiple sets of field values by clicking an add button. <md-content layout-padding=""> <div> <form name="userForm"> <div layout="row ...

How to implement a delay in JQUERY animations?

I have implemented a JQUERY animate function to display a banner on the top of my page. The banner is actually a DIV that is initially set at top -60 in order to hide it. Here is the JavaScript code I am using to show the div: // Animation $('#messag ...

What could be causing the image URL to not function properly in the CSS file?

I have been struggling with this issue all day and have searched numerous sources for answers. The login.css file can be found at: WebContent/resources/css/login.css The image file is located here: WebContent/resources/img/pencil.jpg Despite my attem ...

Best practices for ensuring that your JS file properly interacts with content fetched via AJAX using jQuery

After seeking help for a code issue previously, I have come across another question. I recently watched an AJAX tutorial (https://www.youtube.com/watch?v=WwngGtboldU) to understand how to prevent specific sections of a website from loading. In the tutoria ...

AngularJS - Bootstrap Datepicker with custom format 'mm-yyyy' still permits users to input date in 'mm-yy' format

After incorporating the bootstrap datepicker into an angular directive and applying it to a textbox, everything appears to be functioning correctly except for the validation aspect. Although I have configured it to only accept dates in 'mm-yyyy' ...

Utilizing jQuery to retrieve the URL of a specific anchor element

Trying to traverse through the cells of a table where each cell is structured as follows: <td><a href="javascript:__doPostBack..." class="MyLink">1</a></td> I am attempting to extract the href's value from this structure, but ...

Developing an Expandable Menu for Easy Navigation

I am looking to create a collapsible master navigation bar that will have another collapsible navigation bar inside. I already have one collapsible navigation bar, but I can't figure out how to make a master navigation bar that contains it. In the cod ...

Increase jQuery value by X each time it is clicked

I'm trying to create a custom next/prev navigation where clicking the "next" button will animate the margin left by X on each click until reaching the end (-320px), with a similar method for the back button. Here is the JavaScript code I've been ...

Jquery ajax is replacing spaces with %20 in its storage method

In my CodeIgniter view, I have a jQuery ajax function that is used to store a textfield value in a MySQL database table. The issue I'm facing is that the white spaces in the data are being stored as %20. I'm not sure if this problem lies within t ...

Model binding lacks an input validation method

I am working on a basic Razor page view that contains the following form fields: <div class="col-sm-6"> <label asp-for="Input.FirstName" class="form-label"&g ...

CSS media query that prioritizes styling for large screens over small screens

I am currently working on making my new website development project mobile responsive, but I am encountering some strange behavior that is quite frustrating. I am hoping someone can help me figure out what mistake I may be making here. Whenever I test the ...