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

Thanks

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%"));
}
commented: Nice example +8

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

.classname1 {width: 100%;}
.classname2 {width: 50%;}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.