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

  • Home
  • SEARCH
  • 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 8165009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:26:27+00:00 2026-06-06T19:26:27+00:00

For a responsive template, I have a media query in my CSS: @media screen

  • 0

For a responsive template, I have a media query in my CSS:

@media screen and (max-width: 960px) {
    body{
       /*  something */
       background: red;
    }
}

And, I made a jQuery function on resize to log the width:

$(window).resize( function() {
    console.log( $(window).width() );
    console.log( $(document).width() ); /* same result */
    /* something for my js navigation */
}

And there a difference with CSS detection and JS result, I have this meta:

<meta content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, width=device-width" name="viewport"/> 

I suppose it’s due to the scrollbar (15 px). How can I do this better?

  • 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-06T19:26:28+00:00Added an answer on June 6, 2026 at 7:26 pm

    You’re correct about the scroll bar, it’s because the CSS is using the device width, but the JS is using the document width.

    What you need to do is measure the viewport width in your JS code instead of using the jQuery width function.

    This code is from http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/

    function viewport() {
        var e = window, a = 'inner';
        if (!('innerWidth' in window )) {
            a = 'client';
            e = document.documentElement || document.body;
        }
        return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to bootstrap-responsive.css file,the media query @media (max-width: 767px) is repeated meaning it occurs
I am trying to build a responsive email template but have run into some
On this page (responsive site in progress) the background image of the containing div
In the paradigm of responsive design it's easy to hide stuff via css like
I have a responsive layout and I've created a fading panels animated element with
I have a problem with starting a media session and to combine it with
Main question is how to customize bootstrap responsive css? My code partly works but
As a result of our client needing a responsive (CSS) website and the requirement
I have a weird problem, I want to add a global query using context
I have a jinja template with the usual boilerplate links, one of them being

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.