0

I've been tearing my hair out for awhile with this one and I feel like it must be so much easier than I'm making it. I want to resize a div based on the number of elements that will fit inside of a given page width.

For example, if my page width is 1000px, and I have three elements side by side that are 300px each, which are all in a separate container, I'd like to make the container 900px and center that inside the page. If my page width went down to 700px, then the container would be resized at 600px, etc.

Math-wise, it would be something like this:

round(100% / 300px) * 300px 

but I've had absolutely no luck getting something like that to even calculate properly.

yawnr
  • 35
  • 8
  • 2
    You understand that Sass doesn't know how wide your element is, right? – cimmanon Jan 21 '16 at 16:52
  • Yeah -- I guess this wasn't really a Sass question, and a better way of asking this would've been "Is there a way of doing floor division using calc", but I don't think there is, so I had to do it in JS. Thanks! – yawnr Jan 23 '16 at 14:37

0 Answers0