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 7518045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:38:28+00:00 2026-05-30T01:38:28+00:00

I have a jquery function that changes an image depending on scroll position. This

  • 0

I have a jquery function that changes an image depending on scroll position. This works fine when I am using my normal stylesheet but when my media queries kick in and the original values change my jquery function instead of getting the media query value it still works on the original value in the stylesheet. Is there a way to define so jquery will carab the actual value that is being used currently?

This is the jquery function:

var scpos = function(){
  $(window).scroll(function(){
    var wwidth = $(window).width();
    var spos1 = wwidth - 371;
    var spos2 = spos1+wwidth;
    var spos3 = spos2 + wwidth;
    var spos4 = spos3 + wwidth + $('.rightporto').width();
    var spos5 = spos4 + wwidth + $('.leftclients').width();

     if(($(window).scrollLeft() >= 0)&& ($(window).scrollLeft() <= spos1)){
                  $(".step").css('background','url(img/naboutus.png) 94% 5% no-repeat fixed');
              } else if(($(window).scrollLeft() > spos1)&& ($(window).scrollLeft() <= spos2)){
                  $(".step").css('background','url(img/nwhatwedo.png) 94% 5% no-repeat fixed');
              } else if(($(window).scrollLeft() > spos2 )&& ($(window).scrollLeft() <= spos3)){
                  $(".step").css('background','url(img/ntheory.png) 94% 5% no-repeat fixed');
              } else if(($(window).scrollLeft() > spos3)&& ($(window).scrollLeft() <= spos4)){
                  $(".step").css('background','url(img/nportfolio.png) 94% 5% no-repeat fixed');
              } else if(($(window).scrollLeft() > spos4)&& ($(window).scrollLeft() <= spos5)){
                  $(".step").css('background','url(img/nclients.png) 94% 5% no-repeat fixed');
              }else {
                  $(".step").css('background','url(img/ncontacts.png) 94% 5% no-repeat fixed');
              }



        });

This is where I call it

$(window).resize(function() {
scpos();
})
.resize();//trigger the resize event on page load

My main stylesheet value for rightporto class:

.rightporto{
     float:left;
 width:2484px;
}

And this is my media query value for rightporto class depending on resolution for example 1366px width:

@media screen and (min-width: 1281px) and (max-width: 1366px) {
          .rightporto{width:2000px;}
     }

So my problem as you can see is that the jquery function only grabs the class rightporto width in my main stylesheet which is width: 2484px . So when I have a resolution of 1366 width instead of getting the class rightporto width:2000px it still gets the main one of 2484px;

Any suggestions?

  • 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-05-30T01:38:29+00:00Added an answer on May 30, 2026 at 1:38 am

    CSS3 “media queries” are not yet implemented in all major browsers. Is it possible that the #rightporto { width:2000px; } directive is not implemented?

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

Sidebar

Related Questions

I have this jquery code that changes the image of the background on click:
Here's the story... I have a jQuery function that does something, this function is
I have a jQuery selector with following syntax: $('input[type=image]').not('.xyzClass').click(function{ //some functionality }); So this
I currently have a jQuery function that replaces an image when clicked. For instance:
I have a function resizePreview() that will resize an image in a jQuery dialog
I have a jQuery post function that returns a response on success after the
I have a jquery-ajax function that sends data to a php script and the
I have a jQuery setInterval function named timerIncrement that times out (stops incrementing the
I have some jQuery code that intercepts links clicked on a page: $(document).ready(function() {
I have done various tests and I have found that the jQuery validate function

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.