# @csstools/postcss-exponential-functions 中文文档

规范地址：https://npmcn.com/package/%40csstools/postcss-exponential-functions/

版本：3\.0\.9
npm 元数据更新时间：2026-10-02T15:56:17.001Z
中文译文更新时间：2026-11-11T03:27:30.533Z
软件包许可：MIT-0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40csstools/postcss-exponential-functions
原文对照：https://npmcn.com/package/%40csstools/postcss-exponential-functions/?lang=original
项目主页：https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-exponential-functions#readme
源码仓库：https://github.com/csstools/postcss-plugins

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：5.9 kB，6 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=20\.19\.0
- 运行依赖：3 个
- peer 依赖：postcss ^8\.4
- 首次发布：2023-07-24T16:21:03.865Z
- 最新版本发布：2026-10-02T15:56:16.855Z
- 近 30 天下载量：14048479（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：30（近 12 个月 10 个）

## 中文简介

在 CSS 中使用 pow (), sqrt (), switcht (), log (), exp () 指数函数

## 安装

```sh
npm install @csstools/postcss-exponential-functions
```

也可以使用：`pnpm add @csstools/postcss-exponential-functions`、`yarn add @csstools/postcss-exponential-functions`、`bun add @csstools/postcss-exponential-functions`

## README

# PostCSS 指示函数 [![PostCSS Logo](https://postcss.github.io/postcss/logo.svg)](https://github.com/postcss/postcss)

`npm install @csstools/postcss-exponential-functions --save-dev`

[PostCSS 指示函数](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-exponential-functions) 让你使用 `pow()`, (中文(简体) ), `sqrt()`, (中文(简体) ), `hypot()`, (中文(简体) ), `log()`, (中文(简体) ), `exp()` 函数 [CSS 值 4 规格](https://www.w3.org/TR/css-values-4/#exponent-funcs)。 。 。 .

```css
.foo {
    top: calc(1px * pow(2, 3));
    line-height: sqrt(1.2);
    padding: hypot(3px, 4px);
    order: log(10, 10);
    min-height: calc(e - exp(1));
}

/* becomes */

.foo {
    top: calc(8px);
    line-height: calc(1.09545);
    padding: calc(5px);
    order: calc(1);
    min-height: calc(0);
}
```

## 使用量

添加 [PostCSS 指示函数](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-exponential-functions) 对您的项目:

```bash
npm install postcss @csstools/postcss-exponential-functions --save-dev
```

当作一个 [邮政](https://github.com/postcss/postcss) 插件 :

```js
const postcss = require('postcss');
const postcssExponentialFunctions = require('@csstools/postcss-exponential-functions');

postcss([
    postcssExponentialFunctions(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
```

## 选项

### 保护

这个 `preserve` 选项决定原始标记是否 被保存下来。 默认情况下,它没有被保存.

```js
postcssExponentialFunctions({ preserve: true })
```

```css
.foo {
    top: calc(1px * pow(2, 3));
    line-height: sqrt(1.2);
    padding: hypot(3px, 4px);
    order: log(10, 10);
    min-height: calc(e - exp(1));
}

/* becomes */

.foo {
    top: calc(8px);
    top: calc(1px * pow(2, 3));
    line-height: calc(1.09545);
    line-height: sqrt(1.2);
    padding: calc(5px);
    padding: hypot(3px, 4px);
    order: calc(1);
    order: log(10, 10);
    min-height: calc(0);
    min-height: calc(e - exp(1));
}
```

## 常见问题

### @csstools/postcss-exponential-functions 是什么？

在 CSS 中使用 pow \(\), sqrt \(\), switcht \(\), log \(\), exp \(\) 指数函数

### 如何安装 @csstools/postcss-exponential-functions？

在项目目录运行 npm install @csstools/postcss-exponential-functions，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：postcss（^8\.4）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @csstools/postcss-exponential-functions 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @csstools/postcss-exponential-functions 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @csstools/postcss-exponential-functions 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=20\.19\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @csstools/postcss-exponential-functions 可以商用吗？

@csstools/postcss-exponential-functions 使用 MIT-0 许可。声明的许可为 MIT-0，请阅读许可原文确认使用条件。以上为概括，不构成法律意见，请以许可原文为准。

### @csstools/postcss-exponential-functions 的下载量有多少？

根据 npm 官方下载统计，@csstools/postcss-exponential-functions 在 2026/10/11 – 2026/11/09 这 30 天内被下载 14,048,479 次，日均约 468,283 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @csstools/postcss-exponential-functions 还在维护吗？

最新版本 3\.0\.9 发布于 2026/10/02（1 个月前）；至今共发布 30 个版本，其中过去 12 个月发布了 10 个；首次发布于 2023/07/25。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

