[英]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.