通过条件注释共享 LESS CSS 变量
我有一个 LESS 样式表 styles.less
,其中包含一些我需要在 ie7.css
样式表中访问的变量,该样式表是使用条件注释加载的。
鉴于这些是完全独立的样式表,并且考虑到我必须将 ie7.css
转换为 ie7.less
,我是否可以使这些 CSS 变量在跨平台可用两个样式表?
即我希望能够执行以下操作:
# styles.less, always loaded
@labelwidth: 150px;
# ie7.less, sometimes loaded
label{ margin-left: @labelwidth; }
I have a LESS stylesheet styles.less
with some variables that I need to access in my ie7.css
stylesheet, which is loaded using conditional comments.
Given that these are entirely separate stylesheets, and given that I would have to convert ie7.css
to ie7.less
, is it possible for me to make these CSS variables available across the two stylesheets?
i.e. I would like to be able to do something like the following:
# styles.less, always loaded
@labelwidth: 150px;
# ie7.less, sometimes loaded
label{ margin-left: @labelwidth; }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好的方法是仅使用两种不同的样式表:一种适用于所有人,另一种适用于 ie,其中包括所有人的样式表。因此,在 HTML 中,使用智能条件注释,它看起来像:
在
ie.less
中,您可以导入styles.less
:因此,您将获得两个好处:
ie.less
中styles.less
的变量。The best way of doing so is to use only two different stylesheets: one for everyone and one for ie, which includes the everyone's. So, in HTML, using smart Conditional Comments it would look like:
And in
ie.less
you can importstyles.less
:So, you gain two benefits:
styles.less
inie.less
.