더 알아보기/팁

404 페이지 템플릿 사용법

은돌1113 2022. 3. 8. 19:56

1) 구글에 404 페이지 템플릿 검색 → 아래 사이트의 무료 템플릿 활용

 

Colorlib Error 404 V12

A modern, engaging and easy-to-use free crying emoji error page template with a responsive structure and home button.

colorlib.com

 

2) 사용하고 있는 이메일로 구독해서 템플릿 다운 받음

 

3) img, css, html 폴더 안에 있는 코드들을 Next.js에 맞게 변형 시킴

<div id="notfound">
      <div class="notfound">
        <div class="notfound-404">
          <h1>
            4<span></span>4
          </h1>
        </div>
        <h2 className="title">죄송합니다...</h2>
        <p className="content">원하시는 페이지를 찾지 못했습니다.</p>
        <a onClick={urlPush}>홈페이지 바로가기</a>
      </div>
    </div>
/* 404 페이지 css */
* {
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
}

body {
  padding: 0;
  margin: 0;
}

#notfound {
  position: relative;
  height: 100vh;
}

#notfound .notfound {
  position: absolute;
  left: 50%;
  top: 50%;
  -webkit-transform: translate(-50%, -50%);
      -ms-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
}

.notfound {
  max-width: 520px;
  width: 100%;
  text-align: center;
  line-height: 1.4;
}

.notfound .notfound-404 {
  height: 190px;
}

.notfound .notfound-404 h1 {
  font-family: 'Montserrat', sans-serif;
  font-size: 146px;
  font-weight: 700;
  margin: 0px;
  color: #232323;
}

.notfound .notfound-404 h1>span {
  display: inline-block;
  width: 120px;
  height: 120px;
  background-image: url('../img/emoji.png');
  background-size: cover;
  -webkit-transform: scale(1.4);
      -ms-transform: scale(1.4);
          transform: scale(1.4);
  z-index: -1;
}

.notfound h2 {
  font-family: 'Montserrat', sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  text-transform: uppercase;
  color: #232323;
}

.notfound p {
  font-family: 'Montserrat', sans-serif;
  color: #787878;
  font-weight: 300;
}

.notfound a {
  font-family: 'Montserrat', sans-serif;
  display: inline-block;
  padding: 12px 30px;
  font-weight: 700;
  background-color: #f99827;
  color: #fff;
  border-radius: 40px;
  text-decoration: none;
  -webkit-transition: 0.2s all;
  transition: 0.2s all;
}

.notfound a:hover {
  opacity: 0.8;
}

@media only screen and (max-width: 767px) {
  .notfound .notfound-404 {
    height: 115px;
  }
  .notfound .notfound-404 h1 {
    font-size: 86px;
  }
  .notfound .notfound-404 h1>span {
    width: 86px;
    height: 86px;
  }
}

+ img는 피그마에서 1배수, 2배수로 출력해서 사용

 

4) 지금 진행 중인 프로젝트와 자연스럽게 연결하기 위해서 bg style을 추가로 적용했다.

#notfound {
  width: 100%;
  height: 100vh;
  display: absolute;
  background-image: url("/img/index/bg@2x.jpg");
  background-repeat: no-repeat;
  background-size: cover;
}