whatisthis?

Project. ๋ฐ˜์‘ํ˜• ํŽ˜์ด์ง€ - (2) landing page ๋ณธ๋ฌธ

PROJECT/WEB

Project. ๋ฐ˜์‘ํ˜• ํŽ˜์ด์ง€ - (2) landing page

thisisyjin 2022. 3. 2. 12:37

(2) landing page

 

 

๐Ÿ“Œ HTML + CSS ์ž‘์„ฑ

- ๋‚ด๊ฐ€ ์ง์ ‘ ์ฝ”๋”ฉํ•ด๋ณธ ๊ฒƒ ๐Ÿ”ป

 

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Final Project</title>
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link
      href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;700&display=swap"
      rel="stylesheet"
    />
    <link rel="stylesheet" href="grid.min.css" />
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <section class="landing">
      <div class="container">
        <div class="row">
          <div class="col-12">
            <h1 class="landing-title">
              Change your carrer,<br />Change your life
            </h1>
            <p class="landing-desc">
              Get ahead with expert-led training in <br />
              frontend development
            </p>
            <div class="button-group">
              <a href="#" class="fill-button"> Apply now </a>
              <a href="#" class="fill-button inverted"> Learn more </a>
            </div>
          </div>
        </div>
      </div>
    </section>
  </body>
</html>

style.css

/* Landing Page */

.landing {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  background-color: #fdded8;
}

.landing-title {
  color: #2b292d;
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.05em;
  margin-bottom: 24px;
}

.landing-desc {
  margin-bottom: 24px;
}

.fill-button {
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -0.05em;
  padding: 12px 34px;
  background-color: #3040c4;
  color: #fff;
  border-radius: 2px;
  margin: 0 8px;
}

.fill-button.inverted {
  background-color: #fff;
  color: #3040c4;
}

@media screen and (min-width: 768px) {
  .landing-title {
    font-size: 70px;
    line-height: 1.02857143;
    margin-bottom: 32px;
  }

  .landing-desc {
    margin-bottom: 32px;
    font-size: 22px;
  }

  .fill-button {
    padding: 14px 38px;
    font-size: 18px;
    line-height: 1.5555555;
  }
}

(์ง€๋‚œ์‹œ๊ฐ„ ์ž‘์„ฑํ–ˆ๋˜ reset CSS์™€ grid custom๋ถ€๋ถ„์€ ์ƒ๋žตํ–ˆ์Œ.)

 

 

๋ฐ˜์‘ํ˜• ์›น ๋™์ž‘ ํ™•์ธ

 

 

๐Ÿ”Ž ์ด์ƒํ•œ์  + ์ˆ˜์ • ๋กœ๊ทธ

๋”๋ณด๊ธฐ

1. ๋ฒ„ํŠผ ๊นจ์ง ํ˜„์ƒ

์ด๋Ÿฐ์‹์œผ๋กœ ์ฐฝ์ด ์ž‘์•„์ง€๋ฉด ๋ฒ„ํŠผ์ด ์ €๋ ‡๊ฒŒ ๋‘๋™๊ฐ• ๋‚œ๋‹ค.

์•„๋งˆ๋„ button-group์„ ๋ฌด์กฐ๊ฑด ํ•œ์ค„๋กœ ๋‚˜์˜ค๊ฒŒ ํ•ด์•ผํ•˜๋Š”๋ฐ

์ด๊ฒŒ aํƒœ๊ทธ, ์ฆ‰ ์ธ๋ผ์ธ ์š”์†Œ๋ผ์„œ ๊ทธ๋Ÿฐ๊ฐ€๋ณด๋‹ค.

 

์•”ํŠผ ๋‚˜๋Š” display: blockํ•ด์ฃผ๊ณ ,

๊ฐ€๋กœ์ •๋ ฌ์„ ์œ„ํ•ด flex๋ฅผ ์ด์šฉํ•ด์„œ ์ˆ˜์ •ํ–ˆ๋‹ค.

.button-group {
  display: flex;
  justify-content: center;
}

.fill-button {
  display: block;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -0.05em;
  padding: 12px 34px;
  background-color: #3040c4;
  color: #fff;
  border-radius: 2px;
}

.fill-button:first-child {
  margin-right: 8px;
}

๋˜ํ•œ margin์„ ๋‘ ๋ฒ„ํŠผ ๋‘˜๋‹ค margin-right์„ ์ฃผ๋ฉด ๊ฐ€์šด๋ฐ์ •๋ ฌ์ด ์•ˆ๋˜๋ฏ€๋กœ

์ฒซ๋ฒˆ์งธ ๋ฒ„ํŠผ๋งŒ ์ฃผ๊ธฐ ์œ„ํ•ด :first-child๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค.

์ด ๋ฐฉ๋ฒ• ๋ง๊ณ  ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์ด ์žˆ์„ ๊ฒƒ ๊ฐ™๊ธด ํ•œ๋ฐ .. ์šฐ์„ ์€!

 

 

 ์ด๋Ÿฐ์‹์œผ๋กœ ์ด์ œ ๋ฒ„ํŠผ์ด ๊นจ์ง€์ง€๋Š” ์•Š๊ฒŒ ๋˜์—ˆ๋‹ค. ๋‚˜์ด์Šค ๐Ÿ‘

์ด๊ฑธ ํ•ด๊ฒฐํ•˜๋‹ˆ๊นŒ ๋ญ”๊ฐ€ ์ด์ƒํ–ˆ๋˜ ๋ ˆ์ด์•„์›ƒ๋„ ๋‹ค ๊ณ ์ณ์กŒ๋‹ค.

๊ทธ๋ƒฅ ๋ชจ๋“ ๊ฒŒ ๋‹ค aํƒœ๊ทธ๊ฐ€ ์ธ๋ผ์ธ์š”์†Œ์ธ๋ฐ ์–ต์ง€๋กœ ํŒจ๋”ฉ์„ ์ค˜์„œ ์ƒ๊ธด ์ผ์ด์˜€๋‹ค.

(๋ฏธ์•ˆํ•ด ๋ฒ„ํŠผ์•„.. ๐Ÿ˜‚)

 

 

์ตœ์ข… ์ˆ˜์ •ํ•œ style.css ์ฝ”๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

 

* {
  box-sizing: border-box;
  margin: 0;
}

body {
  font-family: "DM Sans", sans-serif;
  width: 100%;
  height: 100vh;
}

/* Reset CSS */

a {
  text-decoration: none;
  color: inherit;
}

button,
input,
textarea {
  font-family: "DM Sans", sans-serif;
  font-size: 16px;
}

button:focus,
button:active,
input:focus,
input:active,
textarea:focus,
textarea:active {
  outline: none;
  box-shadow: none;
}

ul,
ol,
li {
  list-style-type: none;
  padding-left: 0;
  margin-left: 0;
}

p {
  font-size: 16px;
  line-height: 1.5;
  color: #2b292d;
  letter-spacing: 0.01em;
}

/* >= 768px (Desktop) */

@media screen and (min-width: 768px) {
  p {
    font-size: 22px;
    line-height: 1.36363636;
  }
}

/* Custom Grid System - Fix container Width */

@media screen and (min-width: 1200px) {
  .container {
    max-width: 960px !important;
  }
}

/* Landing Page */

.landing {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  background-color: #fdded8;
}

.landing-title {
  color: #2b292d;
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.05em;
  margin-bottom: 24px;
}

.landing-desc {
  margin-bottom: 24px;
}

.button-group {
  display: flex;
  justify-content: center;
}

.fill-button {
  display: block;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -0.05em;
  padding: 12px 34px;
  background-color: #3040c4;
  color: #fff;
  border-radius: 2px;
}

.fill-button:first-child {
  margin-right: 8px;
}

.fill-button.inverted {
  background-color: #fff;
  color: #3040c4;
}

@media screen and (min-width: 768px) {
  .landing-title {
    font-size: 70px;
    line-height: 1.02857143;
    margin-bottom: 32px;
  }

  .landing-desc {
    margin-bottom: 32px;
    font-size: 22px;
  }

  .fill-button {
    padding: 14px 38px;
    font-size: 18px;
    line-height: 1.5555555;
  }
}

 

+) media query๋ถ€๋ถ„์„ ํ•˜๋‚˜๋กœ ํ•ฉ์น ๊นŒ ์ƒ๊ฐ์ค‘์ด๊ธด ํ•œ๋ฐ ๊ฐ ํŽ˜์ด์ง€๋งˆ๋‹ค (์ง€๊ธˆ์€ landing์ด๊ณ )

๋‹ค๋ฅด๊ฒŒ ์„ค์ •ํ•˜๋ฉด ํด๋ž˜์Šค๋‹ˆ ๋ญ๋‹ˆ ํ—ท๊ฐˆ๋ฆด ๊ฒƒ ๊ฐ™์•„์„œ ์•”ํŠผ reset CSS ๋ถ€๋ถ„์— ํ•œ ๊ฒƒ๊ณผ ๊ตฌ๋ถ„ํ•ด๋†“๊ธด ํ–ˆ๋‹ค.

 

 

 

 


 

๐Ÿ“Œ ๊ฐ•์˜๋‚ด์šฉ ์ถ”๊ฐ€ + ์ˆ˜์ •

 

 

 

- ๋ณ€๊ฒฝ 1. 

 

button์˜ padding์„ ์ฃผ๊ธฐ์—” ์• ๋งคํ•œ ์ƒํ™ฉ์ž„.

(์•ˆ์— ๋‚ด๋ถ€ ํ…์ŠคํŠธ๊ฐ€ ๊ธธ์ด๊ฐ€ ๋‹ค๋ฅด๊ธฐ ๋•Œ๋ฌธ)

๋”ฐ๋ผ์„œ, width์™€ height๋ฅผ ์„ค์ •ํ•ด์ฃผ์ž.

 

์ถ”๊ฐ€๋กœ, ๊ฐ€์šด๋ฐ์ •๋ ฌ ๊ฒธ width์„ค์ •์„ ํ•˜๊ธฐ์œ„ํ•ด (inline์ด๋ฉด width์„ค์ • ๋ชปํ•˜๋‹ˆ๊นŒ)

display: inline-flex๋ฅผ ํ•ด์ฃผ์ž.

(๋‚œ ๋งจ์ฒ˜์Œ์— display:block์„ ์ƒ๊ฐํ–ˆ์—ˆ๋‹ค.)

>> ๋ฒ„ํŠผ๋ผ๋ฆฌ inline ์Œ“์ž„์ด ๋˜๋„๋ก inline-flex๋ฅผ ํ•ด์ค€๊ฒƒ์ž„.

 

 

๐Ÿ”ป display: flex

div1
div2

 

๐Ÿ”ป display:inline-flex

inline-flex inline-flex

 

.fill-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 140px;
  height: 48px;
  border-radius: 2px;
  color: #fff;
  background-color: #3040c4;
  font-size: 15px;
  line-height: 1.6;
  font-weight: 700;
  letter-spacing: -0.05em;
}

 

 

์œ„ ํด๋ž˜์Šค๋Š” ํŽ˜์ด์ง€ ๋‚ด ๋ชจ๋“  ๋ฒ„ํŠผ์„ ์น ํ• ๋•Œ ์“ฐ๋ฏ€๋กœ

css ์ƒ๋‹จ์— ๋”ฐ๋กœ ๋นผ๋‘๋Š”๊ฒŒ ์ข‹์Œ.

 

๋˜ํ•œ, button-group์˜ ๊ฒฝ์šฐ์—

ํŽ˜์ด์ง€ ์•ˆ์— button-group์ด ์—ฌ๋Ÿฌ๊ฐœ ์žˆ์„ ์ˆ˜ ์žˆ์œผ๋‹ˆ

์„ ํƒ์ž๋กœ ํ™•์‹คํ•˜๊ฒŒ ํ•˜์—ฌ ์ ๋Š”๋‹ค.

 

.landing .button-group {
  display: flex;
  justify-content: center;
  align-items: center;
}


/* ์•„๋ž˜๋„ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ */

.landing .button-group .fill-button:first-child {
  margin-right: 8px;
}

 

 

 

 

- ๋ณ€๊ฒฝ 2.

 

 landing์˜ width์™€ height๋ฅผ 100%์™€ 100vh๋กœ ๊ฐ๊ฐ ๋”ฐ๋กœ ์„ค์ •ํ•ด์ค˜์•ผํ•จ.

(๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ ์ฝ”๋“œ์—๋Š” ๊ทธ๋ƒฅ body์—๋งŒ ์„ค์ •ํ•˜๊ณ , .landing์— display:flex๋ฅผ ๋จน์—ฌ์คฌ์Œ)

์ง€๊ธˆ์€ ์ž‘๋™ํ•˜์ง€๋งŒ, ์ถ”ํ›„์— ์•„๋ž˜๋กœ ํŽ˜์ด์ง€๋“ค์„ ์ถ”๊ฐ€ํ•˜๋ฉด ์–ด๋–ป๊ฒŒ ํ• ๋ž˜..

 

 

>> ์š”์†Œ๋“ค์„ ๊ฐ์‹ธ๋Š” landing-content๋ฅผ ๋งŒ๋“ค์ž.

<section class="landing">
  <div class="container">
    <div class="row">
      <div class="col-12">
        <div class="landing-content">
          <h1 class="landing-title">
            Change your carrer,<br />Change your life
          </h1>
          <p class="landing-desc">
            Get ahead with expert-led training in <br />
            frontend development
          </p>
          <div class="button-group">
            <a href="#" class="fill-button"> Apply now </a>
            <a href="#" class="fill-button inverted"> Learn more </a>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

 

์ง€๊ธˆ landing์•ˆ์— container>row>col-12 ์ด๋Ÿฐ์‹์œผ๋กœ ์žˆ๋Š”๋ฐ,

์ด ํด๋ž˜์Šค๋“ค์€ grid ์ž์ฒด์˜ ํด๋ž˜์Šค๋ผ์„œ ์–˜๋„ค๋ฅผ ์กฐ์ž‘ํ•ด์ฃผ๋ฉด ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธธ ์ˆ˜ ์žˆ๋‹ค.

 

๋”ฐ๋ผ์„œ, h1, , div(button grp)์„ ๋ฌถ์–ด์ฃผ๋Š” ํฐ ์ปจํ…Œ์ด๋„ˆ๊ฒฉ์ธ landing-content๋ฅผ ๋งŒ๋“ค๊ณ ,

์•„๋ž˜์™€ ๊ฐ™์ด ์Šคํƒ€์ผ์„ ์ ์šฉ์‹œ์ผœ์ฃผ์ž.

 

.landing-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  height: 100vh;
}

 

๋‚ด๊ฐ€ ์ด์ „์— ํ–ˆ๋˜ ๊ฒƒ์€? ๐Ÿ”ป 

.landing {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  background-color: #fdded8;
}

landing์—๋‹ค๊ฐ€ flex๋ฅผ ์„ค์ •ํ–ˆ์—ˆ๋‹ค. (=section ์ „์ฒด์— flex ๋จน์ธ ์…ˆ)

 

์ด์ œ, section์•ˆ์— ๋ชจ๋“  ์š”์†Œ๋ฅผ ๊ฐ์‹ธ๋Š” div์ธ landing-content์— flex๋ฅผ ์„ค์ •ํ•˜๋ฉด

์ž˜ ๋™์ž‘ํ•œ๋‹ค!

 

 

- ๋ณ€๊ฒฝ 3

 

๋ฏธ๋””์–ด์ฟผ๋ฆฌ๋ถ€๋ถ„ ํ•ฉ์น˜๊ธฐ.

(์ด์ „์— reset CSS ์—์„œ ์ž‘์„ฑํ–ˆ๋˜ ๋ฐ˜์‘ํ˜• >> pํƒœ๊ทธ typography ๊ด€๋ จ ์Šคํƒ€์ผ๊ณผ ํ•ฉ์ณ.)

 

- ๋‹จ, ์ฃผ์„์œผ๋กœ ๊ฐ ๋ถ€๋ถ„์„ ์•Œ๊ธฐ์‰ฝ๊ฒŒ

/* landing */ ๊ณผ ๊ฐ™์ด ๋‚˜ํƒ€๋‚ด๊ธฐ.

 

 

@media screen and (min-width: 768px) {
  p {
    font-size: 22px;
    line-height: 1.36363636;
  }

  .fill-button {
    width: 160px;
    height: 56px;
    font-size: 18px;
    line-height: 1.5555555;
  }

  /* Landing */

  .landing-title {
    font-size: 70px;
    line-height: 1.02857143;
    margin-bottom: 32px;
  }

  .landing-desc {
    margin-bottom: 32px;
  }

  .landing .button-group .fill-button:first-child {
    margin-right: 16px;
  }
}

 

 

+) ์ถ”๊ฐ€

 

width >= 768 ์ผ๋•Œ, ์ฆ‰ Desktop์ผ ๋•Œ๋Š”

height๊ฐ€ 100vh์ผ ํ•„์š”๋Š” ์—†๊ณ ,

์ ๋‹นํžˆ ํŒจ๋”ฉ์„ ๋จน์—ฌ์„œ ์ค„์—ฌ๋ฒ„๋ฆฌ๊ฒŒ ๋˜์–ด์žˆ๋‹ค.

 

(๋””์ž์ธ ์‹œ์•ˆ ์ฐธ๊ณ )

 

์šฐ๋ฆฌ๊ฐ€ ์œ„์—์„œ landing-content๋ผ๋Š” div์— width: 100%, height: 100vh๋ฅผ ๋จน์ธ ์ƒํƒœ์ด๋ฏ€๋กœ

์—ฌ๊ธฐ์„œ height๋งŒ ์กฐ์ ˆํ•ด์ฃผ๊ณ , padding์„ ๋‹ค์‹œ ์„ค์ •ํ•ด์ฃผ์ž.

 

.landing-content {
    height: auto;
    padding: 120px 255px;
  }

๐Ÿ’ก ๋ญ”๊ฐ€ ์ด๋ฏธ ์„ค์ •๋œ ์†์„ฑ์„ ์—†์• ๊ณ ์ž ํ• ๋• auto๋ฅผ ์ฃผ๋ฉด ๋œ๋‹ค.

 

height ๋ณ€ํ™”๋ฅผ ์ž˜ ๋ณด์ž

 

 

 

 

 

+) ์ถ”๊ฐ€ ์ดํŽ™ํŠธ - hover

 

(transiton๋„ ์คŒ)

 

.fill-button:hover {
  opacity: 0.5;
}
.fill-button {
  /* ์ดํ•˜ ์ƒ๋žต */
  transition: opacity 300ms ease-in-out;
}

 

 


๐Ÿ”ป Design File

 

Figma

Created with Figma

www.figma.com

 

๐Ÿ”ปReference Lecture

 

๊น€๋ฒ„๊ทธ์˜ HTML&CSS๋Š” ์žฌ๋ฐŒ๋‹ค - ๊ตฌ๋ฆ„EDU

HTML&CSS๋ฅผ ํ•œ๋ฒˆ์—! ํƒ„ํƒ„ํ•œ ๊ฐœ๋…์ดํ•ด๋ถ€ํ„ฐ ์‹ค์Šต๊นŒ์ง€ ํ•œ ๊ฐ•์˜๋กœ ๋๋‚ด๊ธฐ, ์‹ค๋ฌด ๊ฐ€๋Šฅํ•œ ์‹ค๋ ฅ์œผ๋กœ ๐Ÿ˜Ž

edu.goorm.io