
<body>
<div class="container">
<div class="header"></div>
<div class="left-menu"></div>
<div class="right-menu"></div>
<div class="footer"></div>
</div>
</body>
.container {
width: 800px;
}
.header {
width: 100%;
height: 100px;
background-color: aquamarine;
}
.left-menu {
width: 30%;
height: 200px;
background-color: orange;
float: left; //요소를 붕 띄어서 왼쪽정렬
}
.right-menu {
width: 70%;
height: 200px;
background-color: blue;
float: left; //요소를 붕 띄어서 왼쪽정렬
}
.footer {
width: 100%;
height: 300px;
background-color: yellowgreen;
clear: both;
}
nav사용, 기능은 div와 같지만 읽기가 쉬움
<nav>
<ul class="navbar">
<li><a href="https:/www.naver.com">영화</a></li>
<li><a href="https:/www.naver.com">맛집</a></li>
<li><a href="https:/www.naver.com">IT</a></li>
<li><a href="https:/www.naver.com">컴퓨터</a></li>
</ul>
</nav>
.navbar li {
display: inline-block;
width: 80px;
text-align: center;
background-color: #eee;
}
.navbar a {
font-size: 20px;
text-decoration: none;
}
- 테두리가 겹침 : margin collapse 현상
<body>
<div class="main-background">
<h4 class="main-title">Buy Our Shoes!</h4>
<p>할인 전품목 50%</p>
<button>사러가기</button>
</div>
</body>
.main-background {
width: 100%;
height: 500px;
background-image: url("이미지.jpg");
/*여백안남게*/
background-size: cover;
/*가운데부터 채우기*/
background-position: center;
background-repeat: no-repeat;
/*필터조정*/
filter: brightness(100%);
padding: 1px;
text-align: center;
color: black;
font-size: 30px;
}
<body style="margin: 0px">
<div class="main-background">
<h4 class="main-title">Buy Our Shoes!</h4>
<p>할인 전품목 50%</p>
<button class="main-botton">사러가기</button>
</div>
<div class="intro-box">
<strong><p>How we design our shoes</p></strong>
<p>Lorem inpisum doloir dfsflkng nddxz,dmladnmksanflka</p>
</div>
</body>
.main-background {
width: 100%;
height: 500px;
background-image: url("이미지1.jpg");
/*여백안남게*/
background-size: cover;
/*가운데부터 채우기*/
background-position: center;
background-repeat: no-repeat;
/*필터조정*/
filter: brightness(100%);
padding: 1px;
text-align: center;
color: white;
font-size: 30px;
}
.main-background h4 {
padding-top: 100px;
}
.main-botton {
padding: 15px;
font-size: 15px;
background: white;
border: none;
border-radius: 5px;
/*내원래 위치를 기준으로 이동하기*/
position: relative;
top: 20px;
}
.intro-box {
width: 500px;
margin: auto;
padding: 20px;
background-color: gainsboro;
position: relative;
bottom: 50px;
text-align: center;
display: block;
margin-left: auto;
margin-right: auto;
border-radius: 10px;
}
.intro-box p {
padding-top: 5px;
}
브라우저마다 디자인이 다르게 보일수도 있다.
normalize.css 검색해서 사용하면 호환성 이슈를 해결 할 수 있다.
div {
box-sizing: border-box;
}
body{
margin: 0px;
}
<form action="경로" method="방법">
<input type="text" class="text-input" />
<input type="email" />
<input type="password" />
<button type="submit">전송</button>
<select>
<option>사과</option>
<option>포도</option>
</select>
</form>
.text-input[type="text"] {
padding: 10px;
font-size: 20px;
color: blueviolet;
}
<div style="clear: both"></div>를 쓰는 것을 잊지말자<textarea></textarea>를 사용할 경우 최소높이, 최대 높이도 지정이 가능하다 확인해보자!box-sizing : border-box; 사용해서 폭을 줄여주자. css파일 맨 위에 * { box-sizing: border-box;} 설정해도 좋다.<input id="sub" type="checkbox" /> input의 id와 <label for="sub">Subscribe</label> label의 for를 똑같이 지정하면 label 태그의 innertext인 Subscribe 글자를 눌렸을때도 체크가 된다.
<form>
<div class="form-background">
<div class="form-white">
<div class="w-100">
<h3>Contact Us</h3>
<p>Your Email</p>
<input class="form-input" type="email" />
</div>
<div class="w-50">
<p>First Name</p>
<input class="form-input" type="text" />
</div>
<div class="w-50">
<p>Last Name</p>
<input class="form-input" type="text" />
</div>
<div style="clear: both"></div>
<div class="w-100">
<p>Message</p>
<textarea class="form-input form-long"></textarea>
</div>
<div class="check">
<input id="sub" type="checkbox" />
<label for="sub">Subscribe</label>
<button class="yellow-button">SEND</button>
</div>
</div>
</div>
</form>
.form-background {
background-color: black;
padding: 30px;
}
.form-white {
background-color: white;
padding: 30px;
width: 80%;
max-width: 600px;
margin: auto;
}
.form-input {
width: 100%;
padding: 10px;
font-size: 15px;
border: 1px solid black;
border-radius: 5px;
}
.w-50 {
width: 50%;
float: left;
padding: 10px;
}
.w-100 {
width: 100%;
padding: 10px;
}
.check {
width: 100%;
padding: 10px;
}
.yellow-button {
width: 20%;
height: 30px;
float: right;
}
thead는 제목행 tbody는 일반행으로 구분하여 사용하자tr은 행 td는 열을 의미한다.colspan='합칠 셀 갯수'를 추가하자
<body>
<div class="cart-background">
<h2 style="margin: 30px 10px">Your shopping cart</h2>
<table class="cart-table">
<!--제목행은 thead안에 일반행은 tbody안에 넣으면 좋음-->
<thead>
<!--행-->
<tr>
<!--열-->
<td></td>
<td>ITEM</td>
<td>AMOUNT</td>
<td>PRICE</td>
<td>TOTAL</td>
</tr>
</thead>
<tbody>
<tr>
<td><img src="이미지.png" width="70px" /></td>
<td>
<div class="prduct-item">
<span>SONY</span>
<p>FE 70-200 mm F2.8 GM OSS</p>
</div>
<div style="clear: both"></div>
</td>
<td>1</td>
<td>2,000원</td>
<td>2,000원</td>
</tr>
<tr>
<td><img src="이미지.png" width="70px" /></td>
<td>
<div class="prduct-item">
<span>SONY</span>
<p>FE 70-200 mm F2.8 GM OSS</p>
</div>
<div style="clear: both"></div>
</td>
<td>1</td>
<td>4,000원</td>
<td>4,000원</td>
</tr>
<tr>
<!--td옆의 셀 5개를 합쳐주세요-->
<td colspan="5" style="text-align: right">총가격 : 6,000원</td>
</tr>
</tbody>
</table>
<div class="check-cart">
<a href="https://www.naver.com">Edit your shopping cart</a>
<button class="buy-cart-btn">Choose payment method</button>
</div>
</div>
</body>
.cart-background {
width: 100%;
background-color: #c2d3de;
padding: 30px;
}
.cart-table {
width: 100%;
max-width: 700px;
margin: auto;
background-color: white;
border-radius: 10px;
}
.cart-table td,
.cart-table th {
padding: 15px;
border-bottom: 1px solid #c2d3de;
}
/*table은 기본적으로 틈이 존재*/
/*없애려면 border-collapse: collapse 사용*/
table {
border-collapse: collapse;
width: 80%;
margin: auto;
}
.buy-cart-btn {
float: right;
height: 40px;
border: none;
border-radius: 5px;
background-color: navy;
color: white;
}
.check-cart {
margin: 10px;
}
<div class="check-cart">
<a class="custom-link" href="https://www.naver.com"
>Edit your shopping cart</a
>
<button class="buy-cart-btn">Choose payment method</button>
</div>
.buy-cart-btn {
float: right;
height: 40px;
border: none;
border-radius: 5px;
background-color: navy;
color: white;
cursor: pointer;
}
.check-cart {
margin: 10px;
}
/*마우스가 올라가있는 상태*/
.buy-cart-btn:hover {
background-color: chocolate;
}
/*클릭한 상태*/
.buy-cart-btn:active {
background-color: brown;
}
/*focus 커서찍혀있을때*/
.buy-cart-btn:focus {
background-color: grey;
}
.custom-link {
text-decoration: none;
}
/*방문전 글자색*/
.custom-link:link {
color: violet;
}
/*방문후 글자색*/
.custom-link:visited {
color: black;
}
class='덩어리이름__역할--세부특징' <div class="profile">
<img class="profile__imge" />
<h4 class="profile__title"></h4>
<p class="profile__content"></p>
<button class="profile__button--red">버튼1</button>
<button class="profile__button--blue">버튼2</button>
</div>=> OOCSS와 BEM 적절하게 사용<div style="flex-grow: 1"></div> <div class="flex-item">products</div><div class="flex-item">services</div> div박스가 세로로 쌓일 것이다 . display: flex를 해주면 가로 배치가 되는것을 확인 할 수있다.style="flex-grow: 1" 지정하는 것이다. nav 즉, 사단바를 만들고 싶을 때 사용하자 ! flex-grow: 1은 박스의 크기를 조정해준다. 옆으로 길어진 것을 볼 수 있다.
<nav class="flex-container">
<div class="flex-item" style="font-size: 30px">Logo</div>
<div style="flex-grow: 1"></div>
<div class="flex-item">products</div>
<div class="flex-item">services</div>
</nav>
.flex-container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
margin: none;
padding: 10px;
height: 50px;
align-items: center;
background-color: white;
font-size: 20px;
}
.flex-item {
margin: 10px 20px;
}
<meta name="viewport" content="width=device-width, initial-scale=1.0">@media screen and (max-width: 1200px) {
.main-title {
font-size: 20px;
}
.main-intro {
font-size: 15px;
}
}