Pertemuan 6
Cover
Melanjutkan pembelajaran tentang teknologi web dan pengembangan website.
Gallery
What is Grid?
📊 Apa itu CSS Grid?
- Grid = 2D layout system (rows AND columns)
- Powerful untuk template layout kompleks
- Perfect untuk gallery dengan fixed columns
- Lebih kontrol daripada Flexbox untuk structured layout
Flexbox (1D):
Untuk single row/column
Untuk single row/column
Grid (2D):
Untuk rows & columns sekaligus
Untuk rows & columns sekaligus
Grid Example
💻 Grid Code Example
.gallery
{
display : grid ;
grid-template-columns : repeat(3, 1fr) ;
gap : 20px ;
}
display : grid ;
grid-template-columns : repeat(3, 1fr) ;
gap : 20px ;
}
Penjelasan:
•
•
•
•
display: grid
= Aktifkan grid
•
repeat(3, 1fr)
= 3 kolom equal width
•
gap: 20px
= Spacing antar items
Demo Grid Layout
Demo Grid Layout
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Ubah `repeat(3, 1fr)` untuk mencoba 2/3/4 kolom.
Flexbox vs Grid
⚖️ Flexbox vs Grid
🔵 Flexbox (1D Layout)
• Single row atau column
• Lebih fleksibel untuk wrapping
• Cocok untuk navigation, buttons, simple lists
• Single row atau column
• Lebih fleksibel untuk wrapping
• Cocok untuk navigation, buttons, simple lists
🟢 Grid (2D Layout)
• Rows AND columns sekaligus
• Lebih structured & organized
• Cocok untuk gallery, dashboard, template design
• Rows AND columns sekaligus
• Lebih structured & organized
• Cocok untuk gallery, dashboard, template design
💡 Pilihan:
Untuk art gallery kalian, Grid LEBIH COCOK karena punya structure baris & kolom yang jelas!
Activity
🎯 Your Activity
-
Apply Grid to gallery
Update CSS dengandisplay: grid -
Try different column counts
Cobarepeat(2, 1fr),repeat(3, 1fr),repeat(4, 1fr) -
Compare with Flexbox
Mana yang lebih cocok untuk gallery kalian? Flexbox atau Grid? -
Customize styling
Adjust gap, add shadows, borders untuk polish -
Screenshot & share!
Show final gallery layout