简化CSS代码 [英] Simplify CSS code

查看:61
本文介绍了简化CSS代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何简化此代码?

#user_panel .subscribe, 
#user_panel .faves, 
#user_panel .tags,
#user_panel .title,
#user_panel .calendar a,
#user_panel .item .content
{
    color:#fc0;
}

我不想一直写#user_panel。可以吗?

I don`t want to write #user_panel all time. Any ways?

推荐答案

LESS (少用CSS)?

#user_panel {
   .subscribe, .faves, .tags, .title, .calendar a, .item .content {
      color:#fc0;
   }
}

编辑:按评论输入,LESS仅有用如果您使用Ruby。这是完全错误的。 LESS是用Ruby 编写的(不要与仅兼容混淆),并带有命令行工具 less2css 将您的 *。less 文件转换为 *。css 文件。

Accoding to a comment, LESS is only useful if you use Ruby. This is totally wrong. LESS is written in Ruby (do not confuse with only compatible with) and comes with a command-line tool less2css to convert your *.less files to *.css files.

这篇关于简化CSS代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆