2013-03-29 26 views
1

HTML是否可以使用:懸停在:first-child:之後?

<div> 
    <div></div> 
</div> 

CSS

div > :first-child:after { 
    background-color: orange; 
    color: #fff; 
    font-family: sans-serif; 
    font-size: 50px; 
    line-height: 50px; 
    text-align: center; 
    vertical-align: middle; 
    -webkit-font-smoothing: antialiased; 
    content: "hello world"; 
    display: block; 
    font-size: 50px; 
    height: 160px; 
    line-height: 160px; 
    margin-top: 14px; 
    font-weight: normal; 
} 
div > :first-child:after:hover { 
    background-color: #44b800; 
} 

小提琴

http://jsfiddle.net/VSBr6/

基本上,所有我想要做的就是改變backgr徘徊在懸停的顏色,但它似乎並沒有工作。

+0

你不能':hover'一個僞類。 ':之後'和':之前'不這樣工作。 – BenM

+0

謝謝,我認爲是這樣,但在搜索答案時找不到任何東西。 – martincarlin87

回答

6

你可以這樣說:

div:first-child:hover::after { 
    background-color: #44b800; 
} 
+0

啊,非常好,謝謝! – martincarlin87

相關問題