[英]css selector on the body section
是否可以在主体部分内添加CSS选择器? 这是我的示例代码(但不起作用):
<html> <head> </head> <body> <div style= "a[target=_blank] {background-color: yellow;}"> **css selector on this section <a href="http://test.com">test</a> <a href="http://test1.com" target="_blank">test1</a> <a href="http://test2.com" target="_top">test2</a> </div> </body> </html>
不,您不能在内联样式中使用选择器。 内联样式仅会影响样式标签所在的元素。
在样式表中使用css时,似乎工作正常。
据我所知,内联样式仅影响样式处于启用状态的元素,因此不能用于更改其他样式。
a[target=_blank] { background-color: yellow; }
<html> <head> </head> <body> <div> <a href="http://test.com">test</a> <a href="http://test1.com" target="_blank">test1</a> <a href="http://test2.com" target="_top">test2</a> </div> </body> </html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.