Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- sessionStorage
- 소셜로그인
- @
- 카카오로그인
- EC2 is why EC2?
- cookie
- 네트워크
- github
- CSMA/CD
- ssh접속오류
- AWS 가입하기
- Arrays
- 데코레이터
- 영어 Frontend Article 읽고 요약하기 #6
- JWT기본원리
- 무한스크롤
- hub
- git stash
- HTML
- aws
- localStorage
- JavaScript
- 링크이동
- 개발블로그 만들기
- GitClone
- Decorator
- stash
- css기초
- vscode
- google font
Archives
- Today
- Total
바다는 비에 젖지 않는다
[CSS] margin을 이용한 중앙정렬 본문
728x90
코드
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body{
background-color:yellow;
}
.mytitle{
height: 200px;
width: 300px;
background-image: url("https://post-phinf.pstatic.net/MjAyMDAyMjlfMjY4/MDAxNTgyOTU0Nzg3MjQ4.PBMFV4WrSJmeSUJ56c4C7Vkz_SsQlJ1SByKU18kkJh0g.T7mQnadCWVtEZ448AGk_9kG1HFBAzdztXZcBjvSbduwg.JPEG/고양이_나이1.jpg?type=w1200");
background-size: cover;
background-position: center;
border-radius: 10px;
padding-top: 20px;
text-align: center;
color: yellow;
}
.wrap{
width: 300px;
background-color: green;
}
</style>
<link rel="stylesheet" href="../../../Hanghae99/Frontend/prac.css">
</head>
<body>
<div class="wrap">
<div class="mytitle">
<h1>로그인 페이지</h1>
<h4>아이디, 비밀번호를 입력해주세요</h4>
</div>
<p>ID: <input type="text"/></p>
<p>PW: <input type="text"/></p>
<button>로그인 하기</button>
</div>
</body>
</html>

노란색 배경이 <body> 초록색 배경이 <wrap>이다.
<wrap>을 화면 중간을 가져오기 위해 <wrap>태그에 margin: auto 를 추가해주면

이렇게 화면 중앙에 요소를 배치해 줄 수 있다.
728x90
'IT Technical Note > HTML | CSS' 카테고리의 다른 글
| [CSS] Flexbox (0) | 2022.10.07 |
|---|---|
| [CSS] Bootstrap (0) | 2022.10.07 |
| [CSS] 웹페이지에 Google font 이용하기 (0) | 2022.10.07 |
| [CSS] CSS기초 (0) | 2022.10.07 |
| [HTML] HTML 기본 개념 (0) | 2022.10.07 |