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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:56:02+00:00 2026-05-25T00:56:02+00:00

I’m implementing a WordPress theme where content slides into the page vertically. To do

  • 0

I’m implementing a WordPress theme where content slides into the page vertically. To do this, I need to measure the size of the div containing the content without visibly rendering it first. I’m attempting to do all of this without Ajax.

Here’s what I’ve discovered so far:

I can easily load the document, read the size, then hide the div with javascript. Unfortunately there’s a very obvious (and unacceptable) flicker because javascript doesn’t hide the div fast enough. There’s also the issue that if images are placed into the content, I have to wait until they’re rendered to get the true size… no bueno.

The other option is to hide the content with the CSS, but if the user doesn’t have javascript enabled, they’ll just be staring at a blank page.

Which brings me to where I am currently.

I have a piece of javascript that runs immediately after the stylesheet is declared that changes the location of the stylesheet link element and then re-renders the page with a javascript specific stylesheet. This solves the problem of having to hide the content before reading the size.

This was accomplished by positioning the div containing the content absolutely and off the page 9999pixels.

#content {
  position: absolute;
  left: -9999px;
}

At this point, I use jquery to retrieve the height of the content with the following code:

$('#content').height();

The problem is, the number that’s coming back is the incorrect size and is much smaller than the actual content. When I change the css to:

#content {
  position: absolute;
  left: 0px;
}

It renders correctly. What gives?? Is there a bug I don’t know about? This happens in both Chrome and Firefox.

You can view it for yourself here http://thethechad.com/wordpress

— UPDATE ————————————————————————–

I figured out my problem. The div I was using had no specified width. When I moved it outside the flow of the document, it expanded to fill that gap, shifting the content and reducing the height of the element. I went back into my CSS and hardcoded the width and everything is working fine. I feel really dumb. I’m sure we all have those moments. Thanks so much for the help guys!

  • 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-25T00:56:03+00:00Added an answer on May 25, 2026 at 12:56 am

    I’m a bit confused by your long explanation, but here’s how I measure things without anyone seeing them.

    I assign the div a class name I call “measure”. Measure has predefined CSS:

    .measure {
        position: absolute;    // doesn't affect layout
        visibility: hidden;    // not visible, but normal size
        left: -1000px;         // won't affect scrollbars
        top: -1000px;          // won't affect scrollbars
    }
    

    You are then free to get the divs height. Note: it’s width may not be the same as it would be in the layout of the page because divs go full width when position: static.

    If you want to make sure that the object is never seen, then you can give it an initial class of “measure” in it’s original definition and then remove the class later when you want to use the object in the layout of the page.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.