javascript inside css

Reply

Join Date: Oct 2007
Posts: 20
Reputation: nishanthaMe is an unknown quantity at this point 
Solved Threads: 0
nishanthaMe nishanthaMe is offline Offline
Newbie Poster

javascript inside css

 
0
  #1
May 8th, 2008
can we use javascript inside css classes, Because I want to get the browser window width to the css width atribute.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 437
Reputation: Fungus1487 is on a distinguished road 
Solved Threads: 50
Fungus1487's Avatar
Fungus1487 Fungus1487 is offline Offline
Posting Pro in Training

Re: javascript inside css

 
1
  #2
May 8th, 2008
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.
When Autumn Falls [ http://www.whenautumnfalls.co.uk ] &&
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 164
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: javascript inside css

 
0
  #3
May 9th, 2008
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%;}
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC