Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7942441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:58:17+00:00 2026-06-03T23:58:17+00:00

I have several fixed position divs with the same class at varying distances from

  • 0

I have several fixed position divs with the same class at varying distances from the left edge of the window, and I’d like to increase/decrease that distance by an equal amount on each div when a certain action happens (in this case, the window being resized). I’ve tried positioning them with CSS and percentages rather than pixels, but it doesn’t quite do the job.

Is there a way to store the position of each of those divs in an array and then add/subtract a given amount of pixels?

Here’s what I’ve tried so far – I’m still getting my head around JS so this could be really bad for all I know, but here goes:

roomObjects = $('.object-pos');

var objectCount = 0;

for ( var objectCount = 0; objectCount < 10; objectCount++;) {
          roomObjects = rooomObjects[objectCount];
          console.log(roomObjects.css("background-position").split(" "));
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:58:18+00:00Added an answer on June 3, 2026 at 11:58 pm

    Do you mind sharing why percentages wouldn’t work? Usually that’s what I would recommend if you’re wanting the page to scale correctly on window resizes. I guess if you really wanted to you could do something like:

    $(window).resize(function() { 
        $('#whateverdiv').style.whateverproperty = $('#whateverdiv').style.whateverproperty.toString() + (newPosition - oldPosition);
        oldPosition = newPosition;
    }
    

    this is obviously not the complete code, but you should be able to fill in the blanks. You’ll have to set the oldPosition variable on page load with the original position so that the function works the first time.

    edit: you’ll also have to strip off the units from the x.style.property string, so that you’ll be able to add the value to it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several buttons. When clicked I would like to remove all classes from
I have been reading tutorials from several different places like http://css-tricks.com/scrollfollow-sidebar/ or http://jqueryfordesigners.com/fixed-floating-elements/ and
I have a div with several nested divs. All the child div's are float:left
I have a div in fixed position that i like to make it center
I have several divs with id=scroll_1, scroll_2, scroll_3, etc... When any of these divs
I have several entity classes that I use for parsing fixed width text files
I have several projects that need to write structured Textfiles, some with fixed size
I have several strings which look like the following: <some_text> TAG[<some_text>@11.22.33.44] <some_text> I want
I have several file extensions, like .module , that I would like to be
(Briefly, like this question but for Windows servers.) I have several Win2003 servers running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.