[HTML/CSS] 12-1. GridLayout 실습 1

문정준's avatar
Mar 10, 2025
[HTML/CSS] 12-1. GridLayout 실습 1
 
✏️

실습 1

다음 그림과 같이 화면을 배치하시오.
notion image
 

코드 작성

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> * { box-sizing: border-box; } .container { display: grid; grid-template-columns: 1fr 720px 1fr; background-color: rgb(180, 180, 180); padding: 10px; text-align: center; align-items: center; } .content { display: block; background-color: rgb(225, 225, 225); border-radius: 10px; } .title { font-size: 20px; font-weight: bold; color: rgb(255, 141, 141); align-items: center; display: inline-block; } .description { font-size: 16px; font-weight: normal; margin-bottom: 10px; } .img-box { display: inline-block; position: relative; width: 200px; height: 200px; } .img-item { width: 100%; height: 100%; object-fit: cover; } .img-title { position: absolute; width: 100px; top: 50%; left: 25%; font-size: 16px; font-weight: 400; color: rgb(255, 255, 255); } .btn { display: inline-block; width: 200px; height: 40px; border-radius: 10px; text-align: center; line-height: 40px; border: none; } .btn-item { background-color: rgb(201, 64, 0); color: white; width: 150px; height: 25px; font-weight: 700; border-radius: 5px; border: 0.5px solid black; } </style> </head> <body> <div class="container"> <div class="blank-left"></div> <div class="content"> <div class="title"> <h3>Meet Guidebooks</h3> </div> <div class="description">discover hundreds of local spots recommended by Airbnb hosts</div> <div class="img-box"> <div class="img-title">San Francisco</div> <img src="san-francisco.jpg" alt="" class="img-item"> </div> <div class="img-box"> <div class="img-title">New York</div> <img src="new-york.jpg" alt="" class="img-item"> </div> <div class="img-box"> <div class="img-title">London</div> <img src="london.jpg" alt="" class="img-item"> </div> <div class="btn"> <button class="btn-item">See All Guidebooks</button> </div> <hr> <div class="title"> <h3>Just for the Weekend</h3> </div> <div class="description">Discover new, inspiring places close to home</div> <div class="img-box"> <div class="img-title">Napa</div> <img src="napa.jpg" alt="" class="img-item"> </div> <div class="img-box"> <div class="img-title">Sonoma</div> <img src="sonoma.jpg" alt="" class="img-item"> </div> <div class="img-box"> <div class="img-title">San Francisco</div> <img src="san-francisco-2.jpg" alt="" class="img-item"> </div> <div class="btn"> <button class="btn-item">See All Destinations</button> </div> </div> <div class="blank-right"></div> </div> </body> </html>
 

결과 화면

notion image
 
Share article

sxias