阅读(3922) (31)

W3.JS 添加样式

2020-11-02 14:06:37 更新

添加 CSS 属性值:

w3.addStyle(selector,'property','value')

根据Id添加样式

id="London"的元素添加红色背景色:

实例

<button onclick="w3.addStyle('#London','background-color','red')">Add Style</button>

尝试一下 »   添加上CSS »

根据标签添加样式

为所有<h2>元素添加红色背景色:

实例

<button onclick="w3.addStyle('h2','background-color','red')">Add Style</button>

尝试一下 »   添加上CSS »

根据类添加样式

为所有元素添加红色背景色class="city":

实例

<button onclick="w3.addStyle('.city','background-color','red')">Add Style</button>

尝试一下 »   添加上CSS»