English 中文(简体)
保存各年级的数据或数据属性。 哪些是更好的?
原标题:Storing data in classes or styling with data attributes. Which is better?

我有一些内容应当保存其中的一些数据,有些则使用一些风格。

请允许我说,我有4×4网,这样:

rel=“nofollow> http://jsfiddle.net/tM6ze/1/。

我需要储存每个囚室的坐标,并通过javascript加以使用,但也能够单独打造。

我知道,我可以拯救同类数据:

<div class="cell row-3 col-3"></div>

the

我也知道,在 c中可以做的细胞:

.grid .cell[data-row="3"][data-col="3"]{...some style...}

然而,这两种方法都比替代方法(如数据属性的数据和按类别分类的风格)缓慢。

So which one is more effective? Or which one is best in what situations?

I guess i can include both classes and data in the elements (like in the fiddle), but is this the best approach?

最佳回答

我倾向于使用数据,仅仅因为<代码>>> <>}/code>具有多重价值,必须加以分类或配对。

此外,你使用班级的做法相当于一个黑板。 你们正在储存数据;为什么要你使用数据属性?

作为附加,<代码>数据-属性只是一种新型的超文本属性,即使浏览器不支持超文本5(尽管还有比值的工作)。

最后,图书馆(无论大小)都采用了阅读<代码>数据-<>代码>属性(如果你今后使用)的内在方法,将大大简化你的代码。

用你所走的那几门课,就没有任何“wrong>>;这只是不必要的。 数据标签更合适、更清晰、更容易操纵。

问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签