Background Image Width and Height 100% HTML & CSS


Nah, supaya tampilan background bisa melebar otomatis sesuai dengan ukuran resolusi monitor, juga tingginya menyesuaikan menjadi 100%, ada bisa lakukan langkah berikut :


1. Letakkan kode berikut setelah kode
kode :

<img id="main_bg" src="images/bokeh.jpg" />

2. Pasang kode CSS berikut
kode :
#main_bg{
width: 100%;
top: 0;
left: 0;
position: fixed;
z-index: -1;
height:100%;
}

3. Silahkan lihat hasilnya 🙂

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s