login about faq


What I want to do is to set min-height: 100%; in one section tag, and then use the same size in other section tags. So I would need to get the pixel size of that 100%. An example is here. (scroll down when you're there). Thanks!

asked Jul 27 '12 at 11:26

RafalChmiel's gravatar image

RafalChmiel
491138151156

edited Jul 27 '12 at 12:09


Why not add CSS rules for all section tags (Use CSS selectors to select different classes of section tags)? For example:

< style >

    section.mySpecifiedClass {
      min-height: 100%;
    }

< /style >

If you need the height in pixels to send it to the server-side for some computations and math (For example: loading a mini-scaled image to be put inside the section tag in order to save bandwidth and improve performance). Using jQuery.height() would give you what you want:

< script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">< /script >

< script >

  var theWidth = $('section.mySpecifiedClass').height();

  alert(theWidth); //Should alert the height value

< /script >

answered Jul 28 '12 at 21:59

TjWallas's gravatar image

TjWallas
271369

edited Jul 29 '12 at 10:48

Thanks I'll work on that later.

(Jul 29 '12 at 05:30) RafalChmiel RafalChmiel's gravatar image

However how can I pass the "theWidth" variable to CSS?

(Jul 29 '12 at 05:30) RafalChmiel RafalChmiel's gravatar image

It only comes up with "null".

(Jul 29 '12 at 05:34) RafalChmiel RafalChmiel's gravatar image

Well, you can use the same jQuery function to set the height of other section tags on the fly. For example:

<script>
  var theWidth = $('section.mySpecifiedClass').height();
  $('section.myOtherSpecifiedClass').height(theWidth);
</script>

You can also take a look on jQuery.css() for other advanced css modifications on the fly.

(Jul 29 '12 at 09:58) TjWallas TjWallas's gravatar image

I created a Working example for you. Check it out: http://jsfiddle.net/ccHYx/

(Jul 29 '12 at 10:49) TjWallas TjWallas's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported


Join Us in the Chat Room

Tags:

×60
×39
×23
×8
×1

Asked: Jul 27 '12 at 11:26

Seen: 665 times

Last updated: Jul 29 '12 at 10:50