Connecting Tech Pros Worldwide Help | Site Map

how to use javascript in CSS...

  #1  
Old October 3rd, 2008, 10:05 PM
Mike
Guest
 
Posts: n/a
Hi. I've got a page in which the content is within a DIV centered on
the screen. I'm trying to figure out how to deal with the Firefox
issue in which the content shifts to the left whenever the scrollbar
appears.

I found the following bit of code online:

----
var viewport;
var viewport2;

function getViewport(){
// Get viewport width in FF2, Safari 1+, or IE6 w doctype:
if (document.documentElement &&
document.documentElement.clientWidth) {
viewport = document.documentElement.clientWidth;
viewport2 = window.innerWidth; }

// Get viewport width in FF2, Safari 1+, IE5-5.5, or IE6 without a
doctype:
else if (document.body.clientWidth) {
viewport = document.body.clientWidth;
viewport2 = window.innerWidth; }
}
----

I played around with it, and found that "viewport" will give me the
width of the viewing area minus the width of the scrollbar;
"viewport2" gives the width of the viewing area plus the scrollbar.

I'm trying to figure out how to use that information in my CSS
stylesheet. Here's what I'm currently using to position the main
container:

----
#main
{ width: 800px;
margin-left: auto;
margin-right: auto;
}
----

Any thoughts on how to merge the javascript and CSS...?

Thanks much for any help.
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
No TABLES in html. No hacks in CSS. Any layout possible,crossbrowser. Try it. brave1979 answers 53 January 15th, 2008 03:45 PM
how to use javascript for sliding content ken answers 3 February 9th, 2007 07:15 PM
Is it simple to use LineDraw characters in <PRE> mode? John answers 18 August 16th, 2005 10:55 AM
Is there a "target=_blank" alternative in css ? Dimitri Debruyne answers 43 July 20th, 2005 09:01 PM