DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   HTML and CSS (http://www.daniweb.com/forums/forum143.html)
-   -   javascript inside css (http://www.daniweb.com/forums/thread123128.html)

nishanthaMe May 8th, 2008 2:49 am
javascript inside css
 
can we use javascript inside css classes, Because I want to get the browser window width to the css width atribute.

Thanks

Fungus1487 May 8th, 2008 8:09 am
Re: javascript inside css
 
you can use expressions but these are only picked up by internet explorer and are invalid css markup.

.className
{
    width:expression(window.innerWidth ? window.innerWidth + "px" :
        (document.body.offsetWidth ? document.body.offsetWidth + "px" :
            "100%"));
}

MidiMagic May 9th, 2008 7:44 pm
Re: javascript inside css
 
Use the percentage styles to get the browser window width into styles.

.classname1 {width: 100%;}
.classname2 {width: 50%;}


All times are GMT -4. The time now is 3:12 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC