Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tile layout with CSS and HTML

Tags:

html

css

layout

Without relying on tables, what would be a good solution to accomplish a tile layout such as this: tile layout that automatically adapts to the screen size of the user. That is, the whole screen should be filled by the tiles, regardless of the with and height of the resolution.

I appreciate any ideas.

~ Robert

like image 667
orschiro Avatar asked Jul 09 '12 07:07

orschiro


People also ask

How do you make a grid in HTML?

To make an HTML element behave as a grid container, you have to set the display property to grid or inline-grid . Grid containers consist of grid items, placed inside columns and rows.

How do you make a clickable tile in HTML?

You can use javascript to make the cells respond onclick. Alternatively, you can use the a tag behave as a grid, by adding display:block to your . box style class and provide any other css attributes needed. The caveat is that you won't be able to nest other elements inside your a tags.

What is CSS layout?

CSS Grid Layout is a two-dimensional layout system for the web. It lets you lay content out in rows and columns, and has many features that make building complex layouts straightforward. This article will give you all you need to know to get started with page layout, then test your grid skills before moving on.

What is CSS card?

CSS cards are great for organizing and enhancing a website's user interface. Each card is uniquely designed to make it easy for users to read the card content. CSS cards are great for organizing and enhancing a website's user interface. Each card is uniquely designed to make it easy for users to read the card content.


3 Answers

Here is a working example: jsfiddle

Html:

<div class="container">
<div class="first">first</div><div class="third">third</div>
<div class="second">second</div><div class="fourth">fourth</div><div class="last">last</div>
</div>​

CSS:

html, body, .container
{
    height: 100%; 
    min-height: 100%;
}

.first {
    float: left;
    width: 20%;
    height: 30%;
    background-color: red;
}

.second{
    float: left;
    width: 20%;
    height: 70%;
    background-color: green;
}


.third{
    float: right;
    width: 80%;
    height: 80%;
    background-color: blue;
}

.fourth {
    float: right;
    width: 40%;
    height: 20%;
    background-color: #DDDDDD;
}

.last{
    float: right;
    width: 40%;
    height: 20%;
    background-color: yellow;
}

like image 190
Marian Ban Avatar answered Oct 02 '22 00:10

Marian Ban


I would go with some div using absolute positionning. And specify for each tile the width/height/top/left using % unit.

like image 22
Py. Avatar answered Oct 02 '22 00:10

Py.


Hint:

  • Use a "content div" with 100% of width and height
  • Use into the "content div" two divs: one for the left column and one for the right one. Remember to give those "%" dimension (to "content" div also)
  • Remember that a floated right div have to come BEFORE a left floated div

With this three point, you should be able to try yourself.

like image 42
DonCallisto Avatar answered Oct 02 '22 01:10

DonCallisto