..."> ..."/> ..."> ...">

如何为一个HTML容器分配多个类?

html HTML

猴子NearJinJin

2020-03-23

是否可以将多个类分配给单个HTML容器?

就像是:

<article class="column, wrapper"> 

第2728篇《如何为一个HTML容器分配多个类?》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

4个回答
米亚 2020.03.23

像这样删除逗号:

<article class="column wrapper"> 
2020.03.23

从标准

7.5.2元素标识符:id和class属性

属性定义

id = name [CS]
This attribute assigns a name to an element. This name must be unique in a document.

class = cdata-list [CS]
This attribute assigns a class name or set of class names to an element. Any number of elements may be assigned the same class name or names. Multiple class names must be separated by white space characters.

Yes, just put a space between them.

<article class="column wrapper">

Of course, there are many things you can do with CSS inheritance. Here is an article for further reading.

伽罗理查德 2020.03.23

是的,没有逗号。只是一个空间。因为它认为逗号是第一类列的一部分。然后,它使该类column,不起作用。工作代码如下所示:<article class="column wrapper">

伽罗理查德 2020.03.23

要分配多个类给一个html元素,包括类属性的报价中同时类的名字,并让他们相隔的空间:

<article class="column wrapper"> 

在上面的示例中,columnwrapper是两个单独的css类,并且它们的两个属性都将应用于该article元素。

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android