Styling CSS - newbie question

K

kriton

Hi,

As a beginner concerning JavaScript, I need some help in general.
I intend to change css-properties via Script.

In a more natural speech I want to do the following:

If container-width = smaller than viewport
then container-width = 42em;
If container-width is taller than viewport
than container-width = 90% of width of viewport;

That means, if the font-size will increased until the container
is wider than the width of viewport, the container's width should
be 90% of width of viewport, but I don't know, how to realize it.


I wrote this function already:

function myWidth() {
if (document.getElementById) {
var wrapperWidth = document.getElementById('Wrapper').clientWidth;
var viewportWidth = (document.documentElement.clientWidth ?
document.documentElement.clientWidth :
document.body.clientWidth);
var result = viewportWidth - wrapperWidth;
}
alert('Width of viewport: ' + viewportWidth + ' px\nWidth of paragraph:
' + wrapperWidth +
' px\n-------------------------------------\nDifference . . . . . .
' + result + ' px\n\n');
}

Example: <http://www.kriton.de/TEST/mywidth.html>

I wasted several hours by trying a lot of code already,
but I can't get the requested result.


Any help would greatly be appreciated.

Thanks in advance
Kriton
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top