943,896 Members | Top Members by Rank

Ad:
May 8th, 2008
0

javascript inside css

Expand Post »
can we use javascript inside css classes, Because I want to get the browser window width to the css width atribute.

Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nishanthaMe is offline Offline
20 posts
since Oct 2007
May 8th, 2008
1

Re: javascript inside css

you can use expressions but these are only picked up by internet explorer and are invalid css markup.

HTML and CSS Syntax (Toggle Plain Text)
  1. .className
  2. {
  3. width:expression(window.innerWidth ? window.innerWidth + "px" :
  4. (document.body.offsetWidth ? document.body.offsetWidth + "px" :
  5. "100%"));
  6. }
Last edited by Fungus1487; May 8th, 2008 at 9:09 am.
Reputation Points: 66
Solved Threads: 56
Posting Pro in Training
Fungus1487 is offline Offline
459 posts
since Apr 2007
May 9th, 2008
0

Re: javascript inside css

Use the percentage styles to get the browser window width into styles.

HTML and CSS Syntax (Toggle Plain Text)
  1. .classname1 {width: 100%;}
  2. .classname2 {width: 50%;}
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: Font doesn't match in IE & FireFox
Next Thread in HTML and CSS Forum Timeline: space removal from checkbox





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC