Reputation: 3523
I like using mosaic because when a user increases the size of their browser, it will automatically move around to find the best possible fit. 5 columns can resize to four columns quite nicely. I'd like an effect similar to this, but without the "move to find best fit".
Right now I'm using a table to store some data, each cell of size 300x250. The problem arises when a user increases the size of the page, since cells are rigid and will not reduce column size to compensate, and I end up with cells outside the width of the page, necessitating scrolling.
How can I achieve this effect? To summarize:
Is there an easy method to get this tiling scheme? Here's an image to illustrate:
Upvotes: 0
Views: 158
Reputation: 1074445
That's how display: inline-block
elements are laid out. Combine with min-width
if you want them to be uniform rather than dictated by their actual content.
Example: Live Copy
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example</title>
<style>
.box {
display: inline-block;
border: 1px solid black;
min-width: 100px;
text-align: center;
margin-bottom: 2px;
margin-right: 2px;
}
</style>
</head>
<body>
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
</body>
</html>
Note that some old versions of IE don't like you to take an element (like div
) that defaults to display: block
and make it inline-block
instead. If you need to support them, use an element (like span
) that defaults to inline-block
instead.
Upvotes: 1