@euid/scss-mixins
  • Sass 믹스인 라이브러리
  • Getting Started
    • 시작하기
    • 환경 구성
    • 변경 이력
    • VS Code 확장
  • Utilities
    • 단위 (Unit)
      • rem()
      • em()
      • unitless-px()
      • remove-unit()
      • get-number-or-string()
    • 컬러 (Color)
      • get-color()
      • get-color-name()
      • has-color()
      • alt-color()
      • a11y-color()
      • light-or-dark()
      • color-contrast()
      • most-legible-color()
    • 문자 (String)
      • str-replace()
      • str-split()
      • str-to-num()
      • str-repeat()
      • str-extract-count-keyword()
    • 리스트 (List)
      • first()
      • last()
      • copy-list()
      • merge-list()
      • get-value-after-key()
      • get-match-value-of-keys()
    • 검사 (Validation)
      • is-valid-types()
      • is-valid-keywords()
      • is-include-items()
    • 이징 (Easing)
      • ease()
      • ease-add()
      • ease-merge()
  • Mixins
    • 폰트 (Font)
      • font()
      • font-face()
      • font-size-padding()
    • 텍스트 (Text)
      • text()
      • text-ellipsis()
    • 간격 (Spacing)
      • margin()
      • m()
      • mx()
      • my()
      • padding()
      • p()
      • px()
      • py()
      • space()
      • s()
      • sx()
      • sy()
    • 디스플레이 (Display)
      • show()
      • hide()
      • order()
    • 포지션 (Position)
      • position()
      • relative()
      • absolute()
      • fixed()
      • sticky()
      • static()
    • 플렉스박스 (Flexbox)
      • Flex 컨테이너(Container)
        • flex-container()
        • flex-container-append()
      • Flex 아이템(Item)
        • flex-item()
        • flex()
    • CSS 그리드 (Grid)
      • Grid 컨테이너(Container)
        • grid-container()
        • grid-container-append()
          • grid-rows()
          • grid-cols()
          • grid-auto()
            • auto-rows()
            • auto-cols()
            • auto-flow()
          • grid-areas()
          • gap()
      • Grid 아이템(Item)
        • grid-item()
        • grid-area()
        • grid-row()
          • row-start()
          • row-end()
          • row-span()
        • grid-col()
          • col-start()
          • col-end()
          • col-span()
    • 박스 정렬 (Box Alignment)
      • box-alignment()
      • place()
        • content()
        • items()
        • self()
      • justify-content()
      • align-content()
      • justify-items()
      • align-items()
      • justify-self()
      • align-self()
    • 반응형 웹 (Rsponsive Web)
      • media()
      • rwd-img()
      • rwd-video()
      • rwd-iframe-wrapper()
    • 이니셜라이즈 (Initialize)
      • initialize()
      • normalize()
      • reset-box()
      • reset-box-sizing()
      • reset-img()
      • reset-link()
      • reset-list()
      • reset-dl()
      • reset-abbr()
      • reset-button()
    • 인터페이스 (Interface)
      • appearance()
      • selection()
      • scrollbar()
    • 접근성 (Accessibility)
      • a11y-hidden()
      • focus-visible()
    • 상속 (Inheritance)
      • inherit-box-sizing()
      • inherit-pseudo-elements()
    • 폼 (Form)
      • button()
      • input()
      • radio()
      • search()
      • checkbox()
      • placeholder()
      • textarea()
      • select()
      • select-multiple()
Powered by GitBook
On this page
  • 용도
  • 사용법
  • 로직
  • 참고

Was this helpful?

  1. Mixins
  2. 플렉스박스 (Flexbox)
  3. Flex 아이템(Item)

flex-item()

Flex 아이템(Item) 믹스인

PreviousFlex 아이템(Item)Nextflex()

Last updated 4 years ago

Was this helpful?

용도

요소에 설정 가능한 속성을 빠르고 효율적으로 처리할 때 사용하는 믹스인입니다.

Flexbox 아이템 속성

속성

표준 값

0, 양수

0, 양수

content | <width> ( length, percentage, auto 중 하나)

flex-start | center | flex-end | self-start | self-end | baseline | stretch | safe | unsafe | ...

정수 (음수, 0, 양수)

믹스인에 사용 가능한 속성 (값은 연이어 설정)

믹스인에서 사용되는 속성 + 값

컴파일 되는 표준 속성

grow 또는 g + 값

flex-grow

shrink 또는 s + 값

flex-shrink

basis 또는 b + 값

flex-basis

auto | initial | none

flex

self-start | self-center | self-end | self-stretch | self-normal | self-auto | self-baseline | self-first-baseline | self-last-baseline |

self-safe | self-unsafe | self-initial | self-inherit | self-unset

align-self

order 또는 o + 값

order

사용법

flex-item() 믹스인에 설정 가능한 값을 리스트로 전달합니다.

flex-item($args:list)

.usage {
  @include flex-item(self-end s 0 o 10);
}

매개변수(parameter)

유형(type)

필수(required)

기본 값(default)

$args

list

✔︎

위 예시 코드는 아래의 CSS로 컴파일 되어 출력됩니다.

.usage {
  align-self: flex-end;
  flex: 0 0 auto;
  order: 10;
}

flex-item() 믹스인 보다 간추려 쓰기 위한 flex-i() 믹스인 이름도 제공합니다.

.usage {
  @include flex-i(self-end s 0 o 10);
}

로직

flex-item() 믹스인은 다음의 로직에 의해 작성되었습니다.

@mixin flex-item($args) {
  @if $args != null {
    // align-self
    @each $keyword
      in self-auto
      self-normal
      self-start
      self-end
      self-center
      self-stretch
      self-baseline
      self-first-baseline
      self-last-baseline
      self-safe
      self-unsafe
      self-inherit
      self-initial
      self-unset
    {
      $self-value-index: index($args, $keyword);
      @if $self-value-index {
        $self-value: nth($args, $self-value-index);
        @include align-self($self-value, flex);
      }
    }

    @if is-include-items($args, auto initial none) {
      @if index($args, auto) {
        @include flex(auto);
      }
      @if index($args, initial) {
        @include flex(initial);
      }
      @if index($args, none) {
        @include flex(none);
      }
    }

    @if is-include-items($args, grow g shrink s basis b) {
      // flex-grow
      $grow-value: get-match-value-of-keys($args, grow g);
      // flex-shrink
      $shrink-value: get-match-value-of-keys($args, shrink s);
      // flex-basis
      $basis-value: get-match-value-of-keys($args, basis b);

      // flex
      @include flex(
        if($grow-value, $grow-value, 0) if($shrink-value, $shrink-value, 1)
          if($basis-value, $basis-value, auto)
      );
    }

    // order
    $order-value: get-match-value-of-keys($args, order o);
    @if $order-value {
      @include order($order-value);
    }
  }
}
  1. 전달 받은 $args 매개변수를 분석하여 설정 가능한 속성을 처리

  2. order 키워드의 경우 뒤이어 제공된 값과 함께 속성 설정

flex-i() 믹스인은 flex-item() 믹스인 래퍼로 보다 간단하게 쓰기 위해 작성되었습니다.

@mixin flex-i($args) {
  @include flex-item($args);
}

참고

믹스인에 사용된 Sass의 빌트인 모듈은 다음과 같습니다.

믹스인에 사용된 자체 제작한 모듈은 다음과 같습니다.

self-* 키워드 값을 분석해 믹스인 호출

auto , initial , none 키워드를 사용한 경우, 믹스인 호출

grow, shrink , basis 키워드를 사용한 경우, 각 값을 조립해 믹스인에 전달하여 호출

Flex Item
align-self()
flex()
flex()
@mixin / @include
@if / @else
@each
index()
is-include-items()
get-match-value-of-keys()
flex()
order()
align-self()
flex-grow
flex-shrink
flex-basis
align-self
order