<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 미디어쿼리를 사용할 때는 반드시 있어야 함 -->
<!-- w3school viewport라고 검색하면 된다. -->
<meta name="description" content="덴마크 쇼핑몰 카피캣 연습">
<meta name="author" content="김선아">
<meta name="keywords" content="html, css, tutorial">
<title>Helbak</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="css/animation.css">
<link rel="stylesheet" type="text/css" href="css/mobile.css">
</head>
<body>
</body>
</html>
style.css에서 기본적으로 작성해 주어야할 디폴트 css↓
* {
margin: 0;
padding: 0;
box-sizing: border-box;
/* 패딩값을 없애면서 크기가 변형되는 것을 방지하기 위해서 */
}
/* 마진과 패딩값이 기본 적용되는 모든 태그들의 마진과 패딩값을 0으로 설정 */
html, body {
width: 100%;
height: 100%;
}
body {
overflow-x: hidden;
font-family: sans-serif;
color: #585858;
}
h1, h2, h3, h4, h5, h6, p {
font-weight: 400;
/* 폰트 굵기는 100~900까지 100단위로 올라감 */
}
li {
list-style: none;
}
a {
text-decoration: none;
}
img {
vertical-align: middle;
}
span {
display: block;
}
<header id="header">
<h1>
<a href="#" class="logo">
<img src="https://via.placeholder.com/186x18">
</a>
</h1>
<nav class="buttons">
<ul>
<li>
<a href="#" class="menu-button">
<img src="https://via.placeholder.com/22x20">
</a>
</li>
<li>
<a href="#" class="menu-button">
<img src="https://via.placeholder.com/22x20">
</a>
</li>
<li>
<a href="#" class="menu-button">
<img src="https://via.placeholder.com/22x20">
</a>
</li>
</ul>
</nav>
</header>
css↓
/* header */
/* 모바일 버전 (미디어쿼리에서 pc버전을 작성할 예정) */
#header h1 {
background-color: #ffffff;
}
#header h1 .logo {
position: relative;
display: block;
/* h1은 inline성질을 갖고 있다. */
width: 100%;
height: 65px;
background-color: yellow;
}
#header .logo img {
position: absolute;
top: 0;
margin-top: 23px;
left: 50%;
margin-left: -93px;
}
#header .buttons ul {
overflow: hidden;
/* overflow: hidden;을 사용하면 자식의 높이값이 부모에게 영향을 준다. */
}
#header .buttons li {
position: relative;
float: left;
width: 33.33%;
height: 65px;
/*border: solid 5px red;*/ /* 영역표시를 위해 넣었던 것 */
}
#header .buttons .menu-button { /* a태그가 borderbox에 꽉 차게 됨 */
display: inline-block;
width: 100%;
height: 100%;
text-align: center;
}
#header .buttons li:nth-child(1) .menu-button {
background-color: blue;
}
#header .buttons li:nth-child(2) .menu-button {
background-color: pink;
}
#header .buttons li:nth-child(3) .menu-button {
background-color: green;
}
#header .button li .menu-button img {
position: relative;
height: 20px;
top: 50%;
transfrom: translateY(-50%);
/* y축 중앙정렬 하는 방법 */
}