简体   繁体   English

如何替换CSS3中的数据属性(data - *),以便它们在CSS2.1中工作

[英]How to replace data attributes (data-*)in CSS3 so that they work in CSS2.1

I have the following CSS3 code: 我有以下CSS3代码:

[data-class=float1]
    {
        width: 100%;
        float: none;
        margin: 0 0 0.1rem 0;
    }

Now i want to make my page work in IE7/IE8, and as they dont support css3, i need to find alternative for this code in CSS2.1 现在我想让我的页面在IE7 / IE8中运行,并且由于它们不支持css3,我需要在CSS2.1中找到此代码的替代方法

Thanks in advance 提前致谢

There is no CSS2.1 equivalent for rem in CSS3 so you're going to have a bit of trouble with that. CSS3中的rem没有CSS2.1等效,所以你会遇到一些麻烦。 But if you're referring to data attributes, CSS2.1 supports them just fine since attribute selectors were introduced in CSS2.1. 但是,如果您指的是数据属性,CSS2.1支持它们就好了,因为CSS2.1中引入了属性选择器。 There are new attribute selectors in CSS3, but the one you're using is not new. CSS3中有新的属性选择器,但您使用的那个不是新的。

The real problem here is the rem unit, which has limited support (no support in IE 8 or earlier). 这里真正的问题是rem单元,它有限的支持 (在IE 8或更早版本中没有支持)。 In most cases, it can easily be replaced by the use of the em unit, just paying attention to possible effects of font size settings for nested elements. 在大多数情况下,可以通过使用em单元轻松替换它,只需注意嵌套元素的字体大小设置的可能影响。 Just remember that the em unit equals the font size of the current element. 请记住, em单位等于当前元素的字体大小。

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

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