Reputation: 39
I'm using Liquid Slider for my website, I want change my slider's width according to visitor's screen width. I'm using width: 650px for 1366px width, so default rate is ~0.48
I have a JS like this:
function loadwidth() { document.getElementById('main-slider').style.width = "\'" + ((screen.width / 100) * 0.48) + "px\'";
and body in html has:
onlad="loadwidth()"
but it don't change width of my div. How can I fix it?
Upvotes: 0
Views: 568
Reputation: 46
Change it to:
function loadwidth() {
var w = (screen.width / 100) * 0.48;
document.getElementById('main-slider').setAttribute("style","width:"+w+"px");
}
and change:
onload="loadwidth()"
Upvotes: 1