1

我现在正在拔头发,因为 Cufon 要么在玩,要么我想得太复杂了。我有一个跨度链接类,其中包含文本。跨度内的字体颜色应在悬停状态下更改。

Cufon.replace('.info-grid a span', { fontFamily: 'Vegur', hover: true, color: 'white', hoverables: { a: true, span: true } });

使用上面的代码,当你打开网站时,字体是白色的。我认为这是因为上面的代码实际上并没有设置悬停状态,但是我该如何设置呢?我尝试设置 .info-grid a:hover span 类,但它没有用。

CSS...

.info-grid a span {
    position: relative;
    left: 10px;
    top: 80px;
    font-size: 0.94em;
    line-height: 1.3em;
    font-weight: bold;
    text-transform: uppercase;
    color: #009FD4;
    background-color: #ffffff;
}
.info-grid a:hover span {
    color: #fff;
    background-color: #009FD4;
}

HTML

<div class="info-panel" id="info-firstteam">
    <h3>First Team</h3>

         <div class="info-grid">

         <div>
              <a href="../players/profiles/1.html" class="pic-no1">
              <p id="nametext"><span id="firstline">James</span><br><span id="secondline">Tillotson</span></p>
              </a>
         </div>

         <div>
         ...additional divs for players
         </div>

</div>
4

1 回答 1

0

You probably wanted to setup color as part of :hover styling, right? In that case you should put this rule inside hover property, like this:

Cufon.replace('.info-grid a span', { 
  fontFamily: 'Vegur', 
  hover: {
    color: 'white'
  },
  hoverables: { a: true, span: true } 
});

It's said in the documentation, however...

Nesting :hover-enabled elements is unrecommended and may lead to unpredictable results.

... and the way I see it, this notice should be accounted in your case. So maybe it's best to depend on :hover state of a only for changing the colors, replacing the code with this:

Cufon.replace('.info-grid a', { 
  fontFamily: 'Vegur', 
  hover: {
    color: 'white'
  }
});

... as <a> elements are 'hoverable' by default.

于 2012-12-27T16:48:49.357 回答