For Applying Styles to Muitliple classes at once we are going to use dot(.) selector and comma(,). In this article, we will use the dot (.) selector and select all the elements with their class names using the selector and separated by a comma (,).
「class」 是一個HTML屬性,它接受由空格分隔的類別清單。這些類別可以在CSS中用於為特定元素設定樣式,或在javascript中用於操作這些HTML元素。
Example 1
In this example, we will apply the font color “red” to the HTML elements that have classes “header” and “para”. We will achieve this using the dot (.) selector and concatenating them with a comma (, ).
<!DOCTYPE html> <html lang="en"> <head> <title>How to apply styles to multiple classes at once?</title> <style> .header, .para { color: red; } </style> </head> <body> <h3 id="How-to-apply-styles-to-multiple-classes-at-once">How to apply styles to multiple classes at once?</h3> <p class="para">Lorem ipsum dolor sit amet consectetur adipisicing elit.</p> </body> </html>
Example 2
在這個範例中,我們將把字體顏色設為「green」並將字體樣式設定為「italic」套用到具有類別名稱「header」和「para」的HTML元素上。我們將使用點(.)選擇器,並將它們與逗號(,)連接起來來實現這一目標。
<!DOCTYPE html> <html lang="en"> <head> <title>How to apply styles to multiple classes at once??</title> <style> .header, .para { color: green; font-style: italic; } </style> </head> <body> <h3 id="How-to-apply-styles-to-multiple-classes-at-once">How to apply styles to multiple classes at once?</h3> <p class="para">Lorem ipsum dolor sit amet consectetur adipisicing elit.</p> </body> </html>
結論
In this article, we learned how to apply multiple CSS classes at once. We did this by first, selecting multiple classes at once, using the dot (.) selector provided by the the CSS, and then assigning them the quired them thes thes in CSS, and then assigning them the CSS the stylesheet.
以上是如何同時將樣式套用到多個類別?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

了解如何通過Chris Coyier實施WordPress的Gutenberg編輯器來創建一個自定義Codepen塊,並為Sanity Studio提供預覽。

格子呢是一塊圖案布,通常與蘇格蘭有關,尤其是他們時尚的蘇格蘭語。在Tartanify.com上,我們收集了5,000多個格子呢


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

Atom編輯器mac版下載
最受歡迎的的開源編輯器

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

Dreamweaver Mac版
視覺化網頁開發工具

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

WebStorm Mac版
好用的JavaScript開發工具