<table>
태그를 이용하여 간단한 장바구니 레이아웃을 만들어보았다.
주요 키워드: <table>
, pseudo class, nth-child
<table>
<tr>
<td>
<th>
<thead>
, <tbody>
<thead>
안에<tbody>
안에 넣음 좋다<table>
은 기본적으로 틈이 존재<span>
)th: nth-child(2) {
width: 400px;
}
-> 2번째 나오는 th 요소를 선택해서 설정해라
<td colspan="5">
(hover, focus, active를 이용한 인터랙티브 버튼 스타일)
.button {
color:blue;
display: block;
margin-left: auto;
width: auto;
height: 40px;
position: relative;
top: -30px;
cursor: pointer;
}
.button:hover {
background-color: aliceblue;
}
.button:focus {
background-color: aquamarine;
}
.button:active {
background-color: blueviolet;
}
<!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">
<link rel="stylesheet" href="./layout5.css">
<title>Document</title>
</head>
<body>
<div class="background">
<div class="ysc">
<h3>Your Shopping Cart</h3>
</div>
<table class="table">
<thead>
<td style="width:30%"></td>
<td>ITEM</td>
<td>AMOUNT</td>
<td>PRICE</td>
<td>TOTAL</td>
</thead>
<tbody>
<tr>
<td> <img class="img" src="https://cdn.pixabay.com/photo/2014/08/29/14/53/camera-431119_1280.jpg" alt=""></td>
<td> <h4>Sony</h4> <span>FE 70-200 mm F28 GM ASS</span></td>
<td>1</td>
<td>$ 200.00</td>
<td>$ 200.00</td>
</tr>
<tr>
<td> <img class="img" src="https://cdn.pixabay.com/photo/2014/08/29/14/53/camera-431119_1280.jpg" alt=""></td>
<td><h4>Canon</h4><span>FE 70-200 mm F28 GM ASS</span></td>
<td>1</td>
<td>$ 350.00</td>
<td>$ 350.00</td>
</tr>
<tr>
<td colspan="5" style="text-align: right">$ 550.00</td>
</tr>
</tbody>
</table>
<div class="footer">
<a href="">Edit your shopping cart</a>
<button class="button">Choose payment method</button>
</div>
</div>
</body>
</html>
// css 파일
.background {
width: 100%;
padding: 50px;
margin: auto;
box-sizing: border-box;
background: #66a6ff;
position: relative;
}
.table {
background: white;
text-align: center;
margin:auto;
border-collapse: collapse;
}
.button {
color:blue;
display: block;
margin-left: auto;
width: auto;
height: 40px;
position: relative;
top: -30px;
cursor: pointer;
}
.button:hover {
background-color: aliceblue;
}
.button:focus {
background-color: aquamarine;
}
.button:active {
background-color: blueviolet;
}
.footer {
text-align: left;
margin-top: 30px;
}
.img {
width: 100%;
height: 100%;
}
.table td{
padding: 15px;
border-bottom: 1px solid #c2d3de;
}
thead {
font-size: 16px;
font-weight: 800;
}