格式化 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)