如何在WebStorm中美化CSS?

How to beautify CSS in WebStorm?

我想 beautify/reformat CSS 使用 WebStorm 编写代码。

我有这个CSS风格:

.container {
  display     : grid;
  margin      : 0 auto;
  max-width   : 90rem;
  padding-top : 1rem;
}
.cols-2 {grid-template-columns : 50% 50%;}

.logo {font-size : 3rem;font-weight : 600;}
.slogan {font-size : 1.3rem; margin-top : 6px;}

.search {background-image : url("../images/search.svg");background-repeat : no-repeat;background-size : 35px;}

.content {min-height : 500px;}

我想美化成这个CSS风格和WebStorm/IntelliJ:

.container {
  display     : grid;
  margin      : 0 auto;
  max-width   : 90rem;
  padding-top : 1rem;
}

.cols-2 {
  grid-template-columns : 50% 50%;
}

.logo {
  font-size   : 3rem;
  font-weight : 600;
}

.slogan {
  font-size  : 1.3rem;
  margin-top : 6px;
}

.search {
  background-image  : url("../images/search.svg");
  background-repeat : no-repeat;
  background-size   : 35px;
}

.content {
  min-height : 500px;
}

有没有什么方法可以使用标准设置来完成这个,或者我应该安装一些扩展吗?

您需要更改项目的编码风格(为项目的外观设置规则),然后重新格式化代码。

Jetbrain 网站上有关于如何执行此操作的教程。

例如: