Adjust the size of an image based on the amount of images in a row


/ Published in: Rails
Save to your folder(s)

1115px is the width of the containing ul, 206px x 109px is the size of the original images


Copy this code and paste it in your HTML
  1. <% if @players.size > 10 %>
  2. <style type="text/css">
  3. #player_list li img { width: <%= 1115 / @players.size %>px; height: <%= ((206/109.to_f) * (1115 / @players.size)).to_i %>px; }
  4. </style>
  5. <% end %>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.