Reputation: 2096
I'm trying to change background-size using css: I want 100 heights and 100 widths, but do not want to create 10,000 classes. e.g.
// style
.tall {background-size: whatever 200%}
.narrow {background-size: 50% existing}
// javascript
element.className ="tall narrow";
As car as I can tell, I need to specify every possible value, e.g.
.tall1 {background-size: 1% 200%}
.tall2 {background-size: 2% 200%}
.tall3 {background-size: 3% 200%} // etc.
Is there any way round this?
Upvotes: 0
Views: 107
Reputation: 9471
If you're using Javascript, you could dynamically set the values.
element.style.backgroundPosition = value1 + '% ' + value2 + '%';
Upvotes: 2