> For the complete documentation index, see [llms.txt](https://ddzy.gitbook.io/ts-utility-plugins-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ddzy.gitbook.io/ts-utility-plugins-docs/utility/utility-dom/convertpairtocsstext.md).

# convertPairToCSSText

### 说明

&#x20;将给定的`CSS`样式键值对转化为`cssText`字符串

### 源码

<https://github.com/ddzy/ts-utility-plugins/tree/master/src/ddzy/utility/dom/convertPairToCSSText>

### 用法

{% code title="convertPairToCSSText.test.ts" %}

```typescript
import { convertPairToCSSText } from "../../utility/dom/convertPairToCSSText";

describe('convertPairToCSSText', () => {
  test('convertPairToCSSText should extract CSS pair object into truthy cssText.', () => {
    const origin: Partial<CSSStyleDeclaration> = {
      border: '1px dotted red',
      backgroundColor: 'blue',
    };
    const expected = `border: 1px dotted red; background-color: blue; `;

    expect(convertPairToCSSText(origin)).toBe(expected);
  });
});
```

{% endcode %}
