i am trying to figure this out:
i have some html and php:
<div class="main" style="height: 800px">
<div class="head" style="height: 300px"</div>
<div class="container">
<?php
for ($i=0; $i<=$size;$i++){
echo "<div style="/"height: 20px;/">line $i</div>";
}
?>
</div>
</div>
now, what i am trying to do is to find the height of the .container
div and apply it to $size
if the .container
height is 100 then i will do something like: $size = 100 / 20
or something similar.
The issue is that even if i find the div height it is still on the client side and i might have to do some ajax.
Another problem is that if there is no content in the .container
usually there is no height.
in this case i could force the size of .container
to be 800 - 300
but i don't allays know other sizes from different block elements on the page.
i hope i am not to confuse with this question.
any ideas?
Thanks
i am trying to figure this out:
i have some html and php:
<div class="main" style="height: 800px">
<div class="head" style="height: 300px"</div>
<div class="container">
<?php
for ($i=0; $i<=$size;$i++){
echo "<div style="/"height: 20px;/">line $i</div>";
}
?>
</div>
</div>
now, what i am trying to do is to find the height of the .container
div and apply it to $size
if the .container
height is 100 then i will do something like: $size = 100 / 20
or something similar.
The issue is that even if i find the div height it is still on the client side and i might have to do some ajax.
Another problem is that if there is no content in the .container
usually there is no height.
in this case i could force the size of .container
to be 800 - 300
but i don't allays know other sizes from different block elements on the page.
i hope i am not to confuse with this question.
any ideas?
Thanks
Share Improve this question asked Jan 10, 2012 at 18:50 PatrioticcowPatrioticcow 27.1k76 gold badges221 silver badges340 bronze badges 1- 2 You can't make operation with php on client side. It muts be parsed on the server side. Javascript will do the trick. – Michael Sazonov Commented Jan 10, 2012 at 18:53
1 Answer
Reset to default 7Description
You can use jQuery's height()
and width()
method to get the size.
Check out the sample and jsFiddle Demonstration
Sample
html
<div class="container">
MyContent<br><br>
</div>
jQuery
alert($(".container").height())
alert($(".container").width())
More Information
- jsFiddle Demonstration
- jQuery.height()
- jQuery.width()