CSS學習——多元素選擇器
阿新 • • 發佈:2018-12-22
前言
前面有分享我學習到的相鄰選擇器,這裡要分享是多元素選擇器
。
多元素選擇器
多元素選擇器是指有多個元素具有相同的屬性的情況下,運用符號,
來進行多元素選擇,下面看程式碼例項就明白了:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .box1{ width: 200px; } .box2{ width: 300px; } .box3{ width: 400px; } .box1,.box2,.box3{ height: 100px; background-color: red; margin-bottom: 10px; } </style> </head> <body> <div class="box1">box1</div> <div class="box2">box2</div> <div class="box3">box3</div> </body> </html>
上面的程式碼中,我們看到.box1,.box2,.box3{}
這段就是多元素選擇器的使用。