<style> [data-theme=light] .main{ background:red; } [data-theme=dark] .main{ background:blue; } </style> <div data-theme="light"><span class="main">light</span></div> <div data-theme="dark"><span class="main">dark</span></div>
效果如下: