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


Recommended Answers

All 2 Replies

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

     width:expression(window.innerWidth ? window.innerWidth + "px" : 
        (document.body.offsetWidth ? document.body.offsetWidth + "px" : 
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, learning, and sharing knowledge.