【问题标题】:Changing the color of a visited a [closed]更改访问过的颜色 [关闭]
【发布时间】:2015-12-31 09:37:02
【问题描述】:

好的,所以目前我将<a href=""></a> 包裹在我的整个主 div 中以获取图像。但是,我正在努力做到这一点,以便当用户单击该框时,它会将颜色从黑色更改为红色。

我尝试过使用

a: visited {
   background - color: red;
}

但我想这不是那么简单,所以这是我的代码.. 任何帮助都非常感谢,我假设这只能在 Javascript 中完成,老实说我对此一无所知..

<a href="<?php the_permalink(); ?>">
    <div class="hovereffect">
        <div class="thumbnail">
            <?php the_post_thumbnail('singles', array( 'class'  => "img-responsive")); ?>
                <div class="overlay">
                    <h2><?php the_title(); ?></h2>
                </div>
                <div class="caption">
                    <div class="ratings">
                        <p class="pull-right"> </p>
                        <p>
                            Watch Video
                        </p>
                    </div>
                </div>
        </div>
    </div>
</a>

这就是我想要实现的,右侧是当前的状态,我想要更改的是单击图像时的右侧。

样式是这样的

.thumbnail {
    display: block;
    padding: 4 px;
    margin - bottom: 20 px;
    line - height: 1.42857143;
    background - color: #212121;
    border: 1px solid # 191919;
}

【问题讨论】:

  • a:visted -> 错字 -> a:visited
  • @JamesThorpe 更改它时,它仍然什么都不做。
  • 接下来还有其他事情发生。 Docs for visited - 这里绝对不需要 JS。
  • @JamesThorpe 请查看我的编辑
  • @GolezTrol 我想这是因为我把我的课放在那里

标签: javascript jquery css


【解决方案1】:

您实际上可能想要申请的是以下内容:

a:active .thumbnail {
  background-color: #000000;
}

当您开始单击锚点时,这将使缩略图的背景变为黑色。

如果您希望在访问后根据浏览器历史记录进行更改:

a:visited .thumbnail {
  background-color: #000000;
}

【讨论】:

    【解决方案2】:

    a:visted 更改为a:visited

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-11-26
      • 1970-01-01
      • 2020-12-13
      • 1970-01-01
      • 1970-01-01
      • 2016-04-05
      • 2015-09-24
      相关资源
      最近更新 更多