I have a tag <a href="#myDiv">
which links to <div id="myDiv">
...
If I paste this link to browser, like: index.htm#myDiv it goes directly to myDiv. Is it possible to set css which will highlight myDiv when I do this operation?
答案 0 :(得分:2)
当然,您可以使用:target pseudo-class:
:target {
/* Your rules here for the myDiv element */
}
如果需要,您还可以进一步缩小选择器,例如#myDiv:target
。
<强> jsFiddle example 强>