Git Product home page Git Product logo

trilio's Introduction

Trillio Flexbox (Udemy Advanced CSS and Sass)

๐Ÿ”Ž Overview

  • flex-basis, flex-grow๋กœ ์‰ฝ๊ฒŒ ๋น„์œจ์„ ๋‚˜๋ˆ„๊ธฐ
  • align-items: stretch ๊ฐ€ ๊ธฐ๋ณธ๊ฐ’ ์ž„์„ ์•Œ๊ธฐ
    • ์ปจํ…Œ์ด๋„ˆ ๋‚ด๋ถ€์˜ ์•„์ดํ…œ๋“ค์ด cross axis ์ถ• ๋ฐฉํ–ฅ์œผ๋กœ ๊ธธ์ด / ๋„ˆ๋น„๊ฐ€ ๊ฐ™์•„์ง์„ ์ดํ•ด
  • align-self ์†์„ฑ์œผ๋กœ ์•„์ดํ…œ ๊ฐœ๋ณ„์ ์œผ๋กœ cross axis ์ถ•์˜ ์ •๋ ฌ์„ ๊ฒฐ์ •ํ•  ์ˆ˜ ์žˆ์Œ
  • flex์™€ margin: auto ์†์„ฑ์œผ๋กœ space-between๊ณผ ๊ฐ™์€ ํšจ๊ณผ๋ฅผ ์–ป๊ธฐ
  • ๋””์ž์ธ ์žฌ์‚ฌ์šฉ์„ฑ์„ ๋†’์—ฌ์ฃผ๋Š” ์†์„ฑ๋“ค.. inherit, currentColor, transparent
  • flex-wrap, flex-basis ์†์„ฑ์œผ๋กœ n-column layout ๋งŒ๋“ค๊ธฐ
  • box-sizing: content-box๋Š” border ๋•Œ๋ฌธ์— ๋‚ด๋ถ€ ํฌ๊ธฐ๊ฐ€ ์ค„์–ด๋“œ๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•œ๋‹ค.
  • SVG ํŒŒ์ผ์„ ์‚ฌ์šฉํ•˜๊ธฐ
    • sprite.svg ํ•˜๋‚˜์˜ ์ด๋ฏธ์ง€๋กœ ์—ฌ๋Ÿฌ ์•„์ด์ฝ˜์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.
    • fill: var(--color-grey-dark-3); ๋กœ ์ƒ‰์ƒ์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋‹ค
    • background-image๋กœ svgํŒŒ์ผ์„ ๊ฐ€์ ธ์˜ค๋Š” ๋ฐฉ์‹๊ณผ mask ํ”„๋กœํผํ‹ฐ ์‚ฌ์šฉํ•˜๊ธฐ
  • flex box ์™€ ๋ฐ˜์‘ํ˜•
    • side by side ๋ฐฐ์น˜๋ฅผ ์œ„ ์•„๋ž˜๋กœ
    • wrap์œผ๋กœ ๋–จ์–ด๋œจ๋ฆฌ๊ธฐ๋„ ํ•œ๋‹ค.
    • ๋ฐ˜๋Œ€๋กœ side by side ๋ฅผ ์ ์šฉํ•˜๊ณ  ๋‚ด๋ถ€ ์•„์ดํ…œ์„ ๊ท ๋“ฑํ•œ ํฌ๊ธฐ๋ฅผ ๊ฐ–๋„๋ก ํ•  ์ˆ˜ ์žˆ๋‹ค.

๐Ÿ“– Contents

ํ”Œ๋ ‰์Šค ๋ ˆ์ด์•„์›ƒ์˜ ์ดํ•ด

๐Ÿ“ flex-basis, flex-grow๋กœ ์‰ฝ๊ฒŒ ๋น„์œจ์„ ๋‚˜๋ˆ„๊ธฐ

.sidebar {
  flex: 0 0 18%; /* 18% */
}

.hotel-view {
  flex: 1; /* 82% */
}

๐Ÿ“ align-self ์†์„ฑ์œผ๋กœ ์•„์ดํ…œ ๊ฐœ๋ณ„์ ์œผ๋กœ cross axis ์ถ•์˜ ์ •๋ ฌ์„ ๊ฒฐ์ •ํ•  ์ˆ˜ ์žˆ์Œ

  .user-nav {
    display: flex; /* flex ์ปจํ…Œ์ด๋„ˆ์ด์ž */
    align-items: center;  /*(์•„์ดํ…œ๋“ค์€ ์ˆ˜์ง ๊ฐ€์šด๋ฐ ์ •๋ ฌํ•จ)*/
    align-self: stretch; /* flex ์•„์ดํ…œ์ด๋‹ค.(์ž์‹ ์€ ๋Š˜๋ฆฌ๊ณ )*/

๐Ÿ“ align-items: stretch ๊ฐ€ ๊ธฐ๋ณธ๊ฐ’ ์ž„์„ ์•Œ๊ธฐ;๐Ÿ“ flex์™€ margin: auto ์†์„ฑ์œผ๋กœ space-between๊ณผ ๊ฐ™์€ ํšจ๊ณผ๋ฅผ ์–ป๊ธฐ

&__stars {
  /*MEMO: flex: 1์„ ํ•˜๋ฉด ์š”์†Œ์˜ ํฌ๊ธฐ๊ฐ€ ๋Š˜์–ด๋‚˜๊ธฐ ๋•Œ๋ฌธ์—, hover ์ด๋ฒคํŠธ ์‹œ ์ ์šฉ ์˜์—ญ์ด ๋„ˆ๋ฌด ์ปค์ง„๋‹ค.*/
  /* flex: 1 ;*/
  /* MEMO: ์˜†์˜ ์š”์†Œ์™€ ๊ฑฐ๋ฆฌ๋ฅผ ์ตœ๋Œ€ํ•œ ๋ฒŒ๋ฆฌ๊ธฐ ์œ„ํ•ด์„œ margin: auto๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. ์ž๋™์œผ๋กœ ๊ณ„์‚ฐํ•˜์—ฌ ์ตœ๋Œ€ํ•œ margin์„ ์ฃผ๊ฒŒ๋จ.*/
  margin-right: auto;
  /* MEMO: SVG img๋“ค์˜ ๋†’์ด๋ฅผ ๊ฐ™๊ฒŒ ํ•ด์ฃผ๊ธฐ ์œ„ํ•ด ๋ถ€๋ชจ ์š”์†Œ์— flex๋ฅผ ์ ์šฉ์‹œ์ผœ์ฃผ์—ˆ๋‹ค.*/
  display: flex;
}

๐Ÿ“ flex-wrap, flex-basis ์†์„ฑ์œผ๋กœ n-column layout ๋งŒ๋“ค๊ธฐ

display: flex;
flex-wrap: wrap;

&__item {
  flex: 0 0 50%; /* 2-column ์œผ๋กœ ๋ฐฐ์น˜๋œ๋‹ค. */
  margin-bottom: 0.7rem;
}

ํ”Œ๋ ‰์Šค ๋ ˆ์ด์•„์›ƒ๊ณผ ๋ฐ˜์‘ํ˜•์˜ ์กฐํ•ฉ

๐Ÿ“ side by side ๋ฐฐ์น˜๋ฅผ ์œ„ ์•„๋ž˜๋กœ ๋ฐ”๊พธ์–ด์ฃผ๊ธฐ

@media only screen and (max-width: $bp-medium) {
  flex-direction: column;
}

๐Ÿ“ wrap์œผ๋กœ ๋–จ์–ด๋œจ๋ฆฌ๊ธฐ๋„ ํ•œ๋‹ค.

@media only screen and (max-width: $bp-smallest) {
  flex-wrap: wrap;
  align-content: space-around;
  height: 11rem;
}

๐Ÿ“ ๋ฐ˜๋Œ€๋กœ side by side ๋ฅผ ์ ์šฉํ•˜๊ณ  ๋‚ด๋ถ€ ์•„์ดํ…œ์„ ๊ท ๋“ฑํ•œ ํฌ๊ธฐ๋ฅผ ๊ฐ–๋„๋ก ํ•  ์ˆ˜ ์žˆ๋‹ค.

  .side-nav {
    /* ์ƒ๋žต */
    @media only screen and (max-width: $bp-medium) {
      display: flex;
      margin: 0;
    }

    &__item {
      position: relative;

      &:not(:last-child) {
        margin-bottom: 0.5rem;

        @media only screen and (max-width: $bp-medium) {
          margin: 0;
        }
      }

      @media only screen and (max-width: $bp-medium) {
        flex: 1;
      }
    }

๊ธฐํƒ€ ํŒ

๐Ÿ“ SVG ํŒŒ์ผ์„ ์‚ฌ์šฉํ•˜๊ธฐ

  • id๋ฅผ #์œผ๋กœ ๊ตฌ๋ถ„ํ•˜์—ฌ ๋ถˆ๋Ÿฌ์˜จ๋‹ค.

    <svg
      style="position: absolute; width: 0; height: 0; overflow: hidden;"
      version="1.1"
      xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink"
    >
      <defs>
        <symbol id="icon-bookmark" viewBox="0 0 20 20">
          <title>bookmark</title>
          <path
            class="path1"
            d="M14 2v17l-4-4-4 4v-17c0-0.553 0.585-1.020 1-1h6c0.689-0.020 1 0.447 1 1z"
          ></path>
        </symbol>
        <symbol id="icon-chevron-down" viewBox="0 0 20 20">
          <title>chevron-down</title>
          <path
            class="path1"
            d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
          ></path>
        </symbol>
      </defs>
    </svg>
    <svg class="user-nav__icon">
      <use xlink:href="img/sprite.svg#icon-bookmark"></use>
    </svg>
    
    <svg class="user-nav__icon">
      <use xlink:href="img/sprite.svg#icon-chat"></use>
    </svg>
    fill: var(
      --color-grey-dark-3
    ); /* mark up ํ•œ svg ์ด๋ฏธ์ง€๋Š” fill ๋กœ ์ƒ‰์ƒ์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋‹ค. */
  • css ์—์„œ background-image๋กœ svg ์‚ฌ์šฉํ•˜๊ธฐ

    • background-image๋กœ svgํŒŒ์ผ์„ ๊ฐ€์ ธ์˜ค๋Š” ๋ฐฉ์‹(old browser)์€ ์ƒ‰์ƒ ๋ณ€๊ฒฝ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค -> mask๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
    • mask css image ๋ถ€๋ถ„๋งŒ ๋นต๊พธ๋ฝ•(newer browser)ํ•ด์„œ ์ƒ‰์ƒ์„ ๋ณด์ด๊ฒŒ ํ•œ๋‹ค.
    @supports ((-webkit-mask-image: url()) or (mask-image: url())) {
      background-color: var(--color-primary);
      mask-image: url(../img/chevron-thin-right.svg);
      -webkit-mask-image: url(../img/chevron-thin-right.svg);
      mask-size: cover;
      -webkit-mask-size: cover;
    }

๐Ÿ“ box-sizing: content-box๋Š” border ๋•Œ๋ฌธ์— ๋‚ด๋ถ€ ํฌ๊ธฐ๊ฐ€ ์ค„์–ด๋“œ๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•œ๋‹ค.

border: 3px solid #fff; /* border ๊ฐ€ ๋‘๊ป๊ธฐ ๋•Œ๋ฌธ์— ๋‚ด๋ถ€ ํฌ๊ธฐ๊ฐ€ ์ค„์–ด๋“ ๋‹ค.(border-box) */
box-sizing: content-box;

๐Ÿ“ ๋””์ž์ธ ์žฌ์‚ฌ์šฉ์„ฑ์„ ๋†’์—ฌ์ฃผ๋Š” ์†์„ฑ๋“ค

font-size: inherit;
border-bottom: 1px solid currentColor;
background-color: transparent;

trilio's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.