devirkahan
devirkahan

Reputation: 460

How to align elements properly using CSS

My site layout is very simple. I want it to look something like this:

Each red block is text. Right now I just have each block underneath the next one, all centered. I want it to be laid out like the image above.

I cannot seem to figure out how to do this properly. Using relative alignment is a mess. Percentages don't seem to work either.

Upvotes: 0

Views: 63

Answers (2)

sarat
sarat

Reputation: 11160

The websites are divided in to multiple blocks (or columns). It's up to the designer/developer to divide this to independent groups (like sidebar, headers, footers, content etc.)

Learning the fundamentals is quite important. this site has pretty decent intuitive tutorial HTML

Also checkout

Also take cues from the websites you bump into with the help of developer tools packed with browsers.

Upvotes: 2

Blender
Blender

Reputation: 298562

I'd start by breaking it up into big blocks:

A true work of art

From there, just make the structure:

<header>
    ...
</header>

<nav>
    <ul>
        <li>...</li>
        <li>...</li>
        <li>...</li>
        <li>...</li>
    </ul>
</nav>

<aside>
    ...
</aside>

<div id="main">
    <article>
        ...
    </article>

    <article>
        ...
    </article>
</div>

The CSS is pretty simple. Just look up fluid two column layout css and read through one of the many articles out there.

Upvotes: 1

Related Questions