简体   繁体   English

如何在WebStorm中美化CSS?

[英]How to beautify CSS in WebStorm?

I would like to beautify/reformat CSS code using WebStorm.我想使用 WebStorm 美化/重新格式化 CSS 代码。

I have this CSS style :我有这个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;}

I want to beautify it into this CSS style with WebStorm/IntelliJ:我想用 WebStorm/IntelliJ 把它美化成这个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;
}

Are there any ways to accomplish this with standard settings or should I install some extensions?有什么方法可以使用标准设置来完成此操作,还是应该安装一些扩展?

You need to change the coding style of your project (set rules for what the project will look like) and then reformat the code.您需要更改项目的编码风格(为项目的外观设置规则),然后重新格式化代码。

There are tutorials on the Jetbrain website on how to do this. Jetbrain 网站上有关于如何执行此操作的教程。

for example:例如:

You must select 'On colon' from Align Values您必须从对齐值中输入 select 'On colon'

代码风格 > 样式表 > CSS/SCSS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM