由于CSS Scoping Module Level 1草案的状态可以随时更改,我最初的方法并没有奏效很长时间。
在Chrome v33+Enable Experimental Web Platform Features
中,您必须chrome://flags
启用以下代码才能正常工作。
从Chrome Canary v33及其猫选择器开始^^
,答案是:是的!
2014-03-30 更新: Chrome Canary v35+支持最新版本的选择器,即现在所谓的/deep/
选择器。
It styles over all boundaries and also works on native elements.
See: http://codepen.io/Volker_E/pen/jsHFC
/* ... Example for applying to all h2 elements, no matter if DOM or any ShadowDOM subtree ... */
:root ^^ h2 {
font-family: "Arial Black", sans-serif;
}
/* Cr 33+: The "cat" also works on native elements' ShadowDOM */
video ^^ input[type="button"]:first-child {
opacity: .75;
-webkit-filter: drop-shadow( .2rem .2rem .2rem hsla( 5, 100%, 50%, 1 ) );
}
/* Cr 35+: /deep/ also works on native elements' ShadowDOM */
video /deep/ input[type="button"]:first-child {
opacity: .75;
-webkit-filter: drop-shadow( .2rem .2rem .2rem hsla( 5, 100%, 50%, 1 ) );
}