源代码:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>属性选择器</title> <style> /*[id*=section1]{//包含 background-color: green; } [id*=section2]{ background-color: #ff6600; } [id*=section1-1]{ background-color: goldenrod; } [id*=section]{ background-color: #ff6600; } [id^=s]{//s开头 background-color: #b3d4fc; }*/ /*[id$=n1]{ background-color: #ff6600; }*/ [id$=\-1]{ //负号要加\ _不用加 background-color: #e54d26; }
</style> </head> <body> <h1>属性选择器</h1> <div id="section1">section1</div> <div id="section1-1">section1-1</div> <div id="section1-1-1">section1-1-1</div> <div id="section1-1-2">section1-1-2</div> <div id="section1-2">section1-2</div> <div id="section1-2-1">section1-2-1</div> <div id="section2">section2</div> <div id="section2-1">section2-1</div> <div id="section2-2">section2-2</div> </body> </html>
分享知识,分享快乐!希望中国站在编程之巅! ----融水公子 公众微信号:rsgz520 360图书馆馆号:rsgz002.360doc.com
|