开发者

css or javascript add a :hover style to complete line?

I have a PRE tag with a bunch of code in it and several lines. I want to apply a :hover style when a user hovers over a line.

Is there a way 开发者_JAVA技巧I could do this using CSS or Javascript? I looked at :first-line and couldn't find anything.

Any idea?


You have to use the <span class="changeonhover"> tag around each line and then you can have that effect.


pre tags are good way of dumping an array. Its not the best way to display the actual array or data.

If you want to do it in CSS: wrap it around a div

.prediv a:hover{
    background-color:blue;
}

And use:

<div class="prediv"><a href="#"><pre>CONTENT</pre></a></div>

This would hover the whole content not line by line. My suggestion is use ul li tags and do a for loop in JavaScript and dump lines into li.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜