values from javascript using in a stylesheet

  • Thread starter Madame Blablavatsky
  • Start date
M

Madame Blablavatsky

hello,

i have tables and layers in a stylesheet.
the window people use can have a different width and height.

i want to change the width and height of the tables/layers in the stylesheet
depending on the
window width and height of the user.

i know how to get the height and width of the window using javascript, but i
do not know
how to get these values in the stylesheet.

so my question is: how do i get the values from javascript into the
stylesheet?


thanks
 
J

Jonathan N. Little

Madame said:
hello,

i have tables and layers in a stylesheet.
the window people use can have a different width and height.

i want to change the width and height of the tables/layers in the stylesheet
depending on the
window width and height of the user.

i know how to get the height and width of the window using javascript, but i
do not know
how to get these values in the stylesheet.

so my question is: how do i get the values from javascript into the
stylesheet?
You cannot plug in the JavaScript variable values into a stylesheet
AFAIK, but you could use JavaScript to change an element's style
attributes on the fly to do basically the same thing.
 
S

Safalra

Madame said:
i have tables and layers in a stylesheet.
the window people use can have a different width and height.
i want to change the width and height of the tables/layers in the stylesheet
depending on the
window width and height of the user.
i know how to get the height and width of the window using javascript, but i
do not know
how to get these values in the stylesheet.

Seeing as you don't mind being dependent on Javascript, you can alter
the styling of an element through Javascript. Give the element an id
and then use something of the form:

document.getElementById('elementID').style.width=(windowwidth-200)+'px';

Here 'elementID' is the ID you've given the element, and 'windowwidth'
is a variable in which you've put the size of the window. You'll want
to use pixel units as the window size is measured in pixels.

Note however, that it's a really bad idea to make your page dependent
on Javascript, and dynamic resizing can be done through a combination
of 'fluid layout' and well-written stylesheets. Start here if you want
to know more:

http://allmyfaqs.com/faq.pl?AnySizeDesign
 
M

Madame Blablavatsky

Note however, that it's a really bad idea to make your page dependent
on Javascript, and dynamic resizing can be done through a combination
of 'fluid layout' and well-written stylesheets. Start here if you want
to know more:

http://allmyfaqs.com/faq.pl?AnySizeDesign


well, normaly i am programming in php, but now i have to help an
inexperienced designer making a site look good for different resolutions
(800/600 ; 1024 and so on).

i have no experience in doing this so i thought of finding the
windowsize/resolution and using this to set the width/height/top/left etc of
the stylesheet for the objects on the page.

i don't have to use javascript to do this, it is that i just don't know the
best way of doing it.

thanks for your link, it looks interesting
 
A

Andy Dingley

you could use JavaScript to change an element's style
attributes on the fly to do basically the same thing.

A nit-pick:

You can use JavaScript to change the element's style _properties_ on the
fly.

If you try changing _attributes_ as if you were re-writing the HTML
source, then it will have no effect.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top