whatisthis?

Project. ๋ฐ˜์‘ํ˜• ํŽ˜์ด์ง€ - (6) Subscription Section ๋ณธ๋ฌธ

PROJECT/WEB

Project. ๋ฐ˜์‘ํ˜• ํŽ˜์ด์ง€ - (6) Subscription Section

thisisyjin 2022. 3. 2. 20:58

(6) Subscription Section

 

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

 

- html ๋งˆํฌ์—… ๊ตฌ์„ฑ

 

 

์ด๋ฒˆ์—๋Š” section ๋ง๊ณ  aside๋กœ ๊ฐ์‹ธ์ฃผ์ž.

๋””์ž์ธ์‹œ์•ˆ์„ ๋ณด๋ฉด, image๋ถ€๋ถ„๊ณผ ๋‚˜๋จธ์ง€ title+p+form ๋ถ€๋ถ„์œผ๋กœ ๋‚˜๋ˆ ์ง€๊ณ ,

col-12(col-md-5)์™€

col-12(col-md-7)๋กœ ๋‚˜๋ˆˆ๋‹ค.

 

row๋ฅผ ๋‚˜๋ˆ„๋Š” ๊ธฐ์ค€์€ ??? - ์ค„๋ฐ”๊ฟˆ ํ•˜๋ฉด row ๋”ฐ๋กœ ์ ๊ธฐ.

์ด๋ฒˆ์—” ๊ฐ™์€์ค„์— ์žˆ์œผ๋ฏ€๋กœ row>col+col

 

 

 

index.html

<aside class="subscription">
  <div class="container">
    <div class="row">
      <div class="col-12 col-md-5">
        <div class="subscription-image">
          <img src="./assets/img-banner.png" alt="Subscribe us" />
        </div>
      </div>
      <div class="col-12 col-md-7">
        <h1 class="subscription-title">Stay with us</h1>
        <p class="subscription-desc">
          Subscribe to our email newsletter to stay up to date on the latest
          updates
        </p>
        <form action="#" method="POST" class="subscription-form">
          <div class="input-group">
            <input type="email" placeholder="Enter your email" />
            <button type="submit" class="fill-button">Get started</button>
          </div>
          <p class="form-notice">
            Cancel any time. Check out <a href="#">Terms of Use.</a>
          </p>
        </form>
      </div>
    </div>
  </div>
</aside>

๋‚˜์ค‘์— input์„ ๊ฐ€๋กœ์ •๋ ฌ ํ•ด์ฃผ๊ธฐ ์œ„ํ•ด .input-group div๋กœ ๊ฐ์‹ธ์ค€๋‹ค.

(display: flex ์“ธ ์˜ˆ์ •!)

 

 

๐Ÿ”ป ๋‚ด๊ฐ€ ์ž‘์„ฑํ•ด๋ณธ ์ฝ”๋“œ

 

style.css

/* Subscription */

.subscription {
  background-color: #f2f8fa;
  text-align: center;
  padding: 40px 0;
}

.subscription-image {
  padding: 25px;
  margin-bottom: 16px;
}

.subscription-image img {
  display: block;
  width: auto;
  height: 190px;
  margin: 0 auto;
}

.subscription-title {
  margin-bottom: 16px;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.05em;
  color: #2b292d;
}

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

.subscription .input-group {
  margin-bottom: 8px;
}

.subscription .input-group input {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: none;
  border-radius: 2px;
  margin-bottom: 8px;
  color: #7b7b7e;
  background-color: #fff;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.subscription .input-group .fill-button {
  width: 100%;
  cursor: pointer;
}

.subscription-form .form-notice {
  font-size: 13px;
  line-height: 1.5384615;
  letter-spacing: 0;
  color: #7b7b7e;
}

.subscription-form .form-notice a {
  cursor: pointer;
  text-decoration: underline;
  color: #3040c4;
}

 

์ด์ œ desktop ๋ฒ„์ „์˜ ์Šคํƒ€์ผ์„ ์ ์šฉํ•ด๋ณด์ž. (๋ฏธ๋””์–ด์ฟผ๋ฆฌ)

input group์— flex๋ฅผ ์ฃผ์ž.

 

/* ๐Ÿ”บ ์ƒ๋žต - ๋ฏธ๋””์–ด์ฟผ๋ฆฌ */

/* Subscription */

  .subscription {
    text-align: left;
    padding: 80px 0;
  }

  .subscription-image {
    padding: 8px 0;
  }

  .subscription-image img {
    height: 285px;
    margin-left: 0;
  }

  .subscription-title {
    font-size: 40px;
  }

  .subscription .input-group {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
  }

  .subscription .input-group input {
    height: 56px;
    font-size: 18px;
    line-height: 1.3333333;
    margin-bottom: 0;
    margin-right: 8px;
  }

  .subscription .input-group .fill-button {
    flex-shrink: 0;
    width: 160px;
  }

  .subscription-form .form-notice {
    font-size: 14px;
    line-height: 1.7142857143;
  }

 

 

 

๐Ÿ’ก flex-shrink

 

 

์ง€๋‚œ๋ฒˆ ์‹ค์Šต๋•Œ ๋ฐฐ์šด flex-grow์˜ ๋ฐ˜๋Œ€๊ฐœ๋….

flex-grow์˜ ๊ฒฝ์šฐ์—”

container (width: 600px)
item1 (width: 200px) item2 (width: 200px) ๋‚จ๋Š”๊ณต๊ฐ„

์ด๋Ÿฐ ๊ฒฝ์šฐ์— item2์—๊ฒŒ flex-grow: 1์„ ์ฃผ๋ฉด?

 

container (width: 600px)
item1 (width: 200px)                      item2 (width: 400px)                    

์ด๋Ÿฐ์‹์œผ๋กœ ๋‚จ๋Š”๊ณต๊ฐ„๊นŒ์ง€ ์ญ‰ ์ž๋ผ๊ฒŒ ๋œ๋‹ค.

 

 

๋ฐ˜๋Œ€๋กœ, flex-shrink๋Š” ๋ฌด์—‡์ผ๊นŒ?

์šฐ๋ฆฌ๊ฐ€ flex-wrap ์†์„ฑ์„ default๋กœ ๋†”๋‘๋ฉด no-wrap์ด๋‹ค.

no-wrap์€ ๋ฌด์Šจ์ผ์ด ์žˆ์–ด๋„ ํ•œ์ค„๋กœ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฒƒ ์ด๋ฏ€๋กœ

ํ•„์š”์— ์˜ํ•ด์„œ๋Š” ์•ˆ์— ์•„์ดํ…œ๋“ค์˜ ํฌ๊ธฐ๋ฅผ ์ค„์—ฌ๋ฒ„๋ฆฐ๋‹ค.

 

container (width: 600px)
item1 (width: 200px) item2 (width: 500px) >> 100px ์ค„์–ด๋“ฌ

์ด๋•Œ, flex-shrink: 0์„ ์ค€๋‹ค๋ฉด?

item2์— flex-shrink: 0์„ ์ฃผ๋ฉด item2๋Š” ์„ค์ •ํ•œ width๋ฅผ ๋ฐ˜๋“œ์‹œ ์œ ์ง€ํ•œ๋‹ค. (๋‚˜๋จธ์ง€ ์•„์ดํ…œ์ด ์ค„์–ด๋“ฌ)

 

container (width: 600px)
item1 (width:100px) item2 (width: 500px) >> 100px ์ค„์–ด๋“ฌ

 

  .subscription .input-group .fill-button {
    flex-shrink: 0;
    width: 160px;
  }

 

 

์™„์„ฑ!

 


๐Ÿ”ป Design File

 

Figma

Created with Figma

www.figma.com

 

๐Ÿ”ปReference Lecture

 

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

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

edu.goorm.io