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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:37:38+00:00 2026-05-26T17:37:38+00:00

I’ve just realized my plan won’t work with an earlier question . So I

  • 0

I’ve just realized my plan won’t work with an earlier question. So I need some advice.

I’m using javascript variable to get the width and height of all browsers.

var viewportwidth;
var viewportheight;

I and i’m applying these variables to my <div id="wapper"></div> like so…

$("#wrapper").css({
    "width": viewportwidth + 'px !important',
    "height": viewportheight + 'px !important'
});

But I’m also using @media screen for orientation changes on devices in my css.

Which I need to get these variables into it some how, But i’m not sure if it’s best to either output the whole thing as javascript/jquery or if there’s another way of adding a variable into the CSS

<style>

    #wrapper {
        width: viewportheight ;
        height: viewportwidth ;
    }

    /* Landscape */
    @media screen and (orientation:landscape) {

        #wrapper {
            width: viewportwidth !important;
            height: viewportheight !important;
        }

    }

    /* Portrait */
    @media screen and (orientation:portrait) {

        #wrapper {
            width: viewportheight !important;
            height: viewportwidth !important;
        }

    }

</style>

Any advice would be most awesome thanks!

Josh


UPDATE

Here’s another method that I tried but still can’t get it to work…

    $(".portrait").css({
        "width": viewportwidth + 'px !important',
        "height": viewportheight + 'px !important'
    });

    $(".landscape").css({
        "width": viewportheight + 'px !important',
        "height": viewportwidth + 'px !important'
    });

    detectOrientation();
        window.onorientationchange = detectOrientation;
        function detectOrientation(){
            if(typeof window.onorientationchange != 'undefined'){
                if ( orientation == 0 ) {

                    //Do Something In Portrait Mode
                    $("#wrapper").removeClass("landscape").addClass("portrait");

                }
                else if ( orientation == 90 ) {

                    //Do Something In Landscape Mode
                    $("#wrapper").removeClass("portrait").addClass("landscape");

                }
                else if ( orientation == -90 ) {

                    //Do Something In Landscape Mode
                    $("#wrapper").removeClass("portrait").addClass("landscape");

                }
                else if ( orientation == 180 ) {

                    //Do Something In Portrait Mode
                    $("#wrapper").removeClass("landscape").addClass("portrait");

                }
            }
        }
  • 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-26T17:37:39+00:00Added an answer on May 26, 2026 at 5:37 pm

    I feel that you can solve this using css:

    html,body,#wrapper{width:100%;overflow-x:hidden;}
    

    and then you can position your expanding menus absolutely:

    #menu{position:absolute,top:0}
    

    with a margin on the content below the menus

    #content{margin-top:50px}
    

    of course it would help to see the html that you are using.
    The height of the document should be that of the content normally. You should not have to set it with javascript.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the
I have thousands of HTML files to process using Groovy/Java and I need to
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.