sarah3585
sarah3585

Reputation: 637

Jquery set width of div to window then divide

I have a site that has 3 panels it slides through. I want to set the background of each panel to be the window size so I am using:

var width1 = $(document).width(); 

var width2 = $(".nav").width(); 

var width_diff = width1 - width2 + "px";

document.getElementById('test').style.width = width_diff; 

However I want to divide the width by the number of panels as the window size equals the total of them.

Many thanks.

Upvotes: 0

Views: 3217

Answers (1)

Freesnöw
Freesnöw

Reputation: 32143

just change your current line to this:

var width_diff = (width1 - width2) / 3 + "px"

Upvotes: 1

Related Questions