플렉스와 그리드를 이용한 반응형 카드
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flex Card 2</title>
<link rel="stylesheet" href="flexCard2.css">
</head>
<body>
<div class="container">
<div class="card">
<img src="images/coffee.jpg" alt="">
<p>Lorem ipsum dolor sit amet consectetur.</p>
</div>
<div class="card">
<img src="images/teaCup.PNG" alt="">
<p>Lorem ipsum dolor sit amet consectetur.</p>
</div>
<div class="card">
<img src="images/teaSun.jpg" alt="">
<p>Lorem ipsum dolor sit amet consectetur.</p>
</div>
<div class="card">
<img src="images/cold.PNG" alt="">
<p>Lorem ipsum dolor sit amet consectetur.</p>
</div>
<div class="card">
<img src="images/mileCoffee.PNG" alt="">
<p>Lorem ipsum dolor sit amet consectetur.</p>
</div>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
.card {
width: 250px;
height: 300px;
background: lightblue;
margin: 20px;
padding: 10px;
}
img {
width: 100%;
height: 70%;
}
그리드
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Grid Card 2</title>
<link rel="stylesheet" href="gridCard2.css">
</head>
<body>
<div class="container">
<div class="card">
<img src="images/coffee.jpg" alt="">
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Neque, eius.</p>
</div>
<div class="card">
<img src="images/teaCup.PNG" alt="">
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Neque, eius.</p>
</div>
<div class="card">
<img src="images/teaSun.jpg" alt="">
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Neque, eius.</p>
</div>
<div class="card">
<img src="images/cold.PNG" alt="">
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Neque, eius.</p>
</div>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
width: 95%;
margin: 0 auto;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr) );
grid-gap: 20px;
}
.card {
max-width: 100%;
height: 300px;
padding: 10px;
border-radius: 5px;
background: lightblue;
}
img {
width: 100%;
height: 70%;
}
Reference
이 문제에 관하여(플렉스와 그리드를 이용한 반응형 카드), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/webfaisalbd/responsive-card-using-flex-and-grid-48jk텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)