格式化 CSS

重新缩进和排版源代码以便阅读;不能代替运行验证或业务规则检查。

输入: 文本结果: 文本

文本输入

工具选项

案例

Read a responsive two-column card layout

输入

.cards{display:grid;grid-template-columns:repeat(2,1fr);gap:1rem}@media(max-width:40rem){.cards{grid-template-columns:1fr}}

Expected answer

.cards{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:1rem
}
@media(max-width:40rem){
  .cards{
    grid-template-columns:1fr
  }
}
缩进字符串
Inspect focus styles without losing the attribute selector

输入

button[data-state="open"]:focus-visible{outline:2px solid #005fcc;outline-offset:3px}

Expected answer

button[data-state="open"]:focus-visible{
    outline:2px solid #005fcc;
    outline-offset:3px
}
缩进字符串
Trace a custom property through a dark-mode override

输入

:root{--surface:#fff;--ink:#111}.dark{--surface:#111;--ink:#fff}.panel{background:var(--surface);color:var(--ink)}

Expected answer

:root{
	--surface:#fff;
	--ink:#111
}
.dark{
	--surface:#111;
	--ink:#fff
}
.panel{
	background:var(--surface);
	color:var(--ink)
}
缩进字符串
Separate the steps of an opacity animation

输入

@keyframes fade{0%{opacity:0}50%{opacity:.5}100%{opacity:1}}

Expected answer

@keyframes fade{
  0%{
    opacity:0
  }
  50%{
    opacity:.5
  }
  100%{
    opacity:1
  }
}
缩进字符串
Read a print rule that hides navigation

输入

/* Paper copy */@media print{nav,.toolbar{display:none}a{color:#000;text-decoration:underline}}

Expected answer

/* Paper copy */
@media print{
    nav,.toolbar{
        display:none
    }
    a{
        color:#000;
        text-decoration:underline
    }
}
缩进字符串

参数

参数默认值输入与选项
缩进字符串"\\t"支持 \n、\r 和 \t 等转义序列

相关工具

代码整理

操作参考

查看原始技术文档 (English)