I’m building a site with a fluid layout, and therefore need to use percentages in my Jquery sizes and animations. The problem, as I’ve discovered, is that Jquery doesn’t understand percentages. Here’s an example of what I’m after:
The page <body> is 100% wide.
<article> is the width of 71% of the page body.
<hgroup> is the width of 33.2% of <article>
I would like <article> to be the same width as <hgroup> on page load (so that only <hgroup> is showing), then expand to 71% of the page width again when <hgroup> is clicked, allowing the rest of the content within <article> to show. At the same time, I’d like <article> to slide left by the width of <hgroup>, hiding <hgroup>.
Is there any way to make this kind of calculation, or will I have to resort to pixels?
After much frustration and lamentation, I finally got it sorted out. Here’s the code I came up with which, miraculously, works: