# px()

## 용도 <a href="#use" id="use"></a>

[padding()](https://yamoo9.gitbook.io/scss-mixins/mixins/spacing/padding) 믹스인의 `x`축(`left`, `right`) 값을 빠르게 설정하기 위한 단축 믹스인입니다.

## 사용법 <a href="#usage" id="usage"></a>

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

> px($args:**list**)

```ruby
.usage {
  @include px(4.5%);
}
```

| 매개변수(parameter) | 유형(type) | 필수(required) | 기본 값(default) |
| :-------------: | :------: | :----------: | :-----------: |
|      $args      |   list   |      ✔︎      |               |

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

```css
.usage {
  padding-right: 4.5%;
  padding-left: 4.5%;
}
```

#### &#x20;X축 속성의 개별 값을 설정할 경우

```ruby
.usage {
  @include px(5% 10%);
}
```

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

```css
.usage {
  padding-right: 10%;
  padding-left: 5%;
}
```

## 로직 <a href="#logic" id="logic"></a>

`px()` 믹스인은 다음의 로직에 의해 작성되었습니다.&#x20;

```javascript
@mixin px($value) {
  $value_length: length($value);
  @if $value_length == 1 {
    @include p(l $value r $value);
  }
  @if $value_length == 2 {
    @include p(l first($value) r last($value));
  }
}
```

1. 전달 받은 인자의 아이템 개수(length) 확인
2. 개수가 1개인 경우, [p()](https://yamoo9.gitbook.io/scss-mixins/mixins/spacing/padding-p) 믹스인의 인자 값으로 좌(l), 우(r) 값 설정 호출
3. 개수가 2개인 경우, [p()](https://yamoo9.gitbook.io/scss-mixins/mixins/spacing/padding-p) 믹스인의 인자 값으로 좌(l), 우(r) 값 개별 설정 호출

## 참고 <a href="#reference" id="reference"></a>

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

* [@mixin / @include](https://sass-lang.com/documentation/at-rules/mixin)
* [@if / @else](https://sass-lang.com/documentation/at-rules/control/if)
* [length()](https://sass-lang.com/documentation/modules/list#length)

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

* [p()](https://yamoo9.gitbook.io/scss-mixins/mixins/spacing/padding-p)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yamoo9.gitbook.io/scss-mixins/mixins/spacing/px.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
