jQuery/css: Fluid responsive isotope grid with square divs -


i'm trying figure out if @ possible have square divs fluid isotope layout. have 4 column grid, each div being 24% width of container, want these divs perfect squares, can't work out how achieve this.
here's working jsfiddle demo: http://jsfiddle.net/rjzu6/8/
jquery:

var $container = $("#main-grid");  var size = function () {     $container.isotope({         masonry: {             columnwidth: $container.width() / 4         }     }); }  $container.imagesloaded(function () {     $container.isotope({         itemselector: ".grid-block",         animationengine: "jquery",         sortby: "random",         resizable: false,         masonry: {             columnwidth: $container.width() / 4         }     });      size(); });  $(window).smartresize(size); 

css:

#main-grid {      position: absolute;     width: 100%; }  .grid-block {      width: 24%; height: 50px;      margin-left: 0.25%; margin-right: 0.25%;      margin-bottom: 5px;      background: no-repeat 50% 50%;     -webkit-background-size: cover;     -moz-background-size: cover;     -o-background-size: cover;     background-size: cover; } 

the fluidity , functionality works fine, sizes of divs i'm having trouble with. @ possible have perfect square responsive divs?

depending on have inside content, can achieve fluid squares pretty using padding-bottom;

for example

width: 50%; height: 0; padding-bottom: 50%; 

so in this updated fiddle changed css of grid-lock

.grid-block {      width: 24%;       margin-left: 0.25%; margin-right: 0.25%;      margin-bottom: 5px;      background: no-repeat 50% 50%;     -webkit-background-size: cover;     -moz-background-size: cover;     -o-background-size: cover;     background-size: cover;     padding-bottom:24%; } 

here's example of square elements in page

here's more information technique.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -