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
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