我可以为html元素设置一个默认的css类 [英] Can I set a default css class for an html element

查看:116
本文介绍了我可以为html元素设置一个默认的css类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我定义一个css类,有没有将该类设置为html元素的默认类?为了澄清,我希望能够解释类的定义,以便它可以被一个或多个css选择器使用或在html中谨慎应用。

If I define a css class, is there anyway to set that class as a default class for an html element? To clarify, I was hoping to factor out the definition of the class so it could be used by one or more css selectors or applied discreetly in the html.

例如:

.myclass {float:right}
h1 {class: myclass}

当然,上面的工作不行,但是希望你知道我在问什么,因为我还没有找到怎么做。 / p>

The above does not work of course, but hopefully you know what I am asking as I have not been able to find how to do this.

推荐答案

如果你使用像LESS这样的CSS处理器,你可以这样做( http://lesscss.org/#-mixins )或SASS( http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixins )。

You can do that if you are using a CSS processor like LESS (http://lesscss.org/#-mixins) or SASS (http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixins).

这篇关于我可以为html元素设置一个默认的css类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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