我有一个按钮:
.button{
background-color:red;
color:#fff;
width:70px;
}
.button:before{
min-width:0px;
content: attr(data-number);
}
HTML:
<div class="button" data-number="5"><a href="javascript:;">button</a></div>
我的问题是,当用户将鼠标悬停button
文字时,我希望内容编号为黑色。
我试试:
.button:hover .button:before{
color:#000;
}
但它不起作用。
答案 0 :(得分:4)
您需要同时指定String inputFile = "C:\myfile.txt";
FileInputStream in = new FileInputStream(inputFile);
FileChannel ch = in.getChannel();
int BUFSIZE = 512;
ByteBuffer buf = ByteBuffer.allocateDirect(BUFSIZE);
Charset cs = Charset.forName("ASCII");
while ( (rd = ch.read( buf )) != -1 ) {
buf.rewind();
CharBuffer chbuf = cs.decode(buf);
for ( int i = 0; i < chbuf.length(); i++ ) {
if (chbuf.get() == '\n'){
System.out.println("PRINT SOMETHING");
}
}
}
和:hover
:
:before
.button:hover:before {
color:#000;
}
这样的CSS选择器指向.button:hover .button:before
内的.button
。但事实并非如此。
答案 1 :(得分:2)
尝试:
.button:hover::before{
color:#000;
}
您需要同时选择:hover
和::before