Membuat Halaman Rata Tengah dengan CSS

Bagaimana cara membuat sebuah blok pada halaman HTML menjadi rata tengah menggunakan CSS?

Secara sederhana, ada dua cara.

Pertama, untuk liquid layout:

[css]
div#container {
margin-left: 10%;
margin-right: 10%;
}
[/css]

Kedua, untuk fixed-width layout:

[css]
div#container {
margin-left: auto;
margin-right: auto;
width: 50em;
}
[/css]

Penjelasan lebih lanjut bisa dilihat di CSS Centering – fun for all!

Published by Eric Gunawan

Happiness Engineer. WordPress Ambassador. Remote Worker. Soccer News Follower. Movie Lover. Proud Father. Lucky Husband.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: