473,506 Members | 14,630 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CSS and Javascript - height issue

I am having trouble getting an image in my design to stretch correctly
with the main content. Here is a link

http://creativeness.com/temptest/test9.html

Now the image on the left below the navigation (the one that is 65
pixels tall) I want to strech from the bottom of the one image to the
top of the bottom menu. Like on this page

http://creativeness.com/temptest/test10.html

On that page I am trying to use this javascript code

<script language="javascript" type="text/javascript">
var myVar = document.getElementById("siteContent").offsetHeigh t;
var nheight = myVar/10-200+'em';
alert('The height is '+myVar+' the new height is '+nheight );
</script>
<style>
#leftSide5height {
height:nheight;
}
</style>

But it seems that
height:nheight;
isnt the correct way to pass the variable that i determine because it
works if I put a number in there like this
#leftSide5height {
height:50em;
}

Any ideas how to get the correct number and pass the variable? Thanks
for your help.
Aug 4 '08 #1
7 2227
Rabel wrote:
I am having trouble getting an image in my design to stretch correctly
with the main content. Here is a link

http://creativeness.com/temptest/test9.html

Now the image on the left below the navigation (the one that is 65
pixels tall) I want to strech from the bottom of the one image to the
top of the bottom menu. Like on this page

http://creativeness.com/temptest/test10.html

On that page I am trying to use this javascript code

<script language="javascript" type="text/javascript">
var myVar = document.getElementById("siteContent").offsetHeigh t;
var nheight = myVar/10-200+'em';
alert('The height is '+myVar+' the new height is '+nheight );
</script>
<style>
#leftSide5height {
height:nheight;
}
</style>

But it seems that
height:nheight;
isnt the correct way to pass the variable that i determine because it
works if I put a number in there like this
Of course not. The JavaScript var "nheight" is not automatically
expanded with HTML! You would have to have a script run on the
document's onload event, probably with a delay setTimeout to get the
value of "siteContent" after the page loads. Then apply the value to
"leftSide5height".

Seems like a bad idea all around.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Aug 4 '08 #2
On Aug 4, 6:46 pm, "Jonathan N. Little" <lws4...@central.netwrote:
Rabel wrote:
I am having trouble getting an image in my design to stretch correctly
with the main content. Here is a link
http://creativeness.com/temptest/test9.html
Now the image on the left below the navigation (the one that is 65
pixels tall) I want to strech from the bottom of the one image to the
top of the bottom menu. Like on this page
http://creativeness.com/temptest/test10.html
On that page I am trying to use this javascript code
<script language="javascript" type="text/javascript">
var myVar = document.getElementById("siteContent").offsetHeigh t;
var nheight = myVar/10-200+'em';
alert('The height is '+myVar+' the new height is '+nheight );
</script>
<style>
#leftSide5height {
height:nheight;
}
</style>
But it seems that
height:nheight;
isnt the correct way to pass the variable that i determine because it
works if I put a number in there like this

Of course not. The JavaScript var "nheight" is not automatically
expanded with HTML! You would have to have a script run on the
document's onload event, probably with a delay setTimeout to get the
value of "siteContent" after the page loads. Then apply the value to
"leftSide5height".

Seems like a bad idea all around.
Thanks Jonathan,
The script is run after the main content and before the leftSide5 is
called and like I said it works fine if you change that code to

#leftSide5height {
height:50em;
}

so Im not sure if i need to move it or not, but either way I still
dont know how to pass the nheight variable to the height attribute.
Any ideas?
Aug 4 '08 #3

Rabel wrote:
>
http://creativeness.com/temptest/test9.html

Now the image on the left below the navigation (the one that is 65
pixels tall) I want to strech from the bottom of the one image to the
top of the bottom menu. Like on this page

http://creativeness.com/temptest/test10.html
Why do you need to stretch it at all? Why not just use that 65px tall
graphic as a repeating background image down the left side of the
container? You can still get the white spaces between elements over
there by using background and/or border properties.

--
Berg
Aug 5 '08 #4
Rabel schrieb:
On Aug 4, 6:46 pm, "Jonathan N. Little" <lws4...@central.netwrote:
>Rabel wrote:
>>I am having trouble getting an image in my design to stretch correctly
with the main content. Here is a link
http://creativeness.com/temptest/test9.html
Now the image on the left below the navigation (the one that is 65
pixels tall) I want to strech from the bottom of the one image to the
top of the bottom menu. Like on this page
http://creativeness.com/temptest/test10.html
On that page I am trying to use this javascript code
<script language="javascript" type="text/javascript">
var myVar = document.getElementById("siteContent").offsetHeigh t;
var nheight = myVar/10-200+'em';
alert('The height is '+myVar+' the new height is '+nheight );
</script>
<style>
#leftSide5height {
height:nheight;
}
</style>
But it seems that
height:nheight;
isnt the correct way to pass the variable that i determine because it
works if I put a number in there like this
Of course not. The JavaScript var "nheight" is not automatically
expanded with HTML! You would have to have a script run on the
document's onload event, probably with a delay setTimeout to get the
value of "siteContent" after the page loads. Then apply the value to
"leftSide5height".

Seems like a bad idea all around.

Thanks Jonathan,
The script is run after the main content and before the leftSide5 is
called and like I said it works fine if you change that code to

#leftSide5height {
height:50em;
}
THIS is not "Script" - this is inline CSS. It has nothing to do with the
<scriptelement preceding it. You can use JS to set style attributes
but you can't access JS variables or other code from CSS.
so Im not sure if i need to move it or not, but either way I still
dont know how to pass the nheight variable to the height attribute.
Any ideas?
If you use JS to determine the height, why not use JS to *set* it as well?

And please bear in mind that all of that won't work if the user has
turned JS off.
Aug 5 '08 #5
On Aug 4, 8:40 pm, Bergamot <berga...@visi.comwrote:
Why do you need to stretch it at all? Why not just use that 65px tall
graphic as a repeating background image down the left side of the
container? You can still get the white spaces between elements over
there by using background and/or border properties.
Thanks Berg,
Using a repeating background would be fine but I dont know how to tell
it the height of the element.

Christian,
"If you use JS to determine the height, why not use JS to *set* it as
well? "

I just dont know how to "set" this height I thought this would work

height:nheight;

Do you know how I would set the height?

Thanks Guys I really appreciate the help.
Aug 5 '08 #6
Rabel schrieb:
"If you use JS to determine the height, why not use JS to *set* it as
well? "

I just dont know how to "set" this height I thought this would work.
I suggest that you read some elementary text on DOM scripting. What's
the point to use JS if you don't know what your can do with it?

document.getElementById('id').style.height= nheight+'px';

is *one* possibility to achieve what you want. It still only works when
the user has JS turned on.

And maybe you should be a bit more specific in your responses - replying
to two different posts in the same text is not very sensible.
Aug 6 '08 #7

Rabel wrote:
On Aug 4, 8:40 pm, Bergamot <berga...@visi.comwrote:
>Why do you need to stretch it at all? Why not just use that 65px tall
graphic as a repeating background image down the left side of the
container?

Using a repeating background would be fine but I dont know how to tell
it the height of the element.
You shouldn't need to set any explicit height. The container should size
itself according to the content, unless you've done something silly like
absolutely position everything.

--
Berg
Aug 7 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
15722
by: George Hester | last post by:
I have a css file this is a portion of it: /* trackaccept.css */ div.track { width:400px; height: 100px; } I have this in my ASP page:
4
3816
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
3
4535
by: Csaba Gabor | last post by:
How, using javascript, can you set or change a CSS value from something to something else which has the IE proprietary format: expression(javasriptCode)? I'd like to know the answer in...
1
2097
by: Paradox | last post by:
Hi everyone, kinda new to Javascript. Here is the issue, I have a form that sends to a different action based on the button pushed. But it also is sending variables to the server as well. Here...
5
2575
by: settyv | last post by:
Hi, Below is the Javascript function that am trying to call from asp:Button control. <script language="javascript"> function ValidateDate(fromDate,toDate) { var fromDate=new Date();
2
1468
by: haft | last post by:
My webpage of discussion contains a javascript powered image gallery of small thumbnail images that when moused-over, display a larger image that corresponds to the current moused-over thumbnail....
3
1852
by: vanald04 | last post by:
Tried searching for the right article and saw some similar questions that if I knew more would probably be helpful, but I couldn't get the coding exactly right for my specific situation. So, thanks...
0
7308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7479
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
410
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.