dpqvwgr74759 2014-06-05 20:57
浏览 93
已采纳

如何使用css访问<li>链接

I have a small gallery written in PHP, showing images from a directory (webcam pictures).

This is the line where the images shows up in index.php:

<ul id="galleryList" class="clearfix">

            <?php foreach ($galleryArray['images'] as $image): ?>

                <li><a href="<?php echo html_entity_decode($image['file_path']); ?>" rel="colorbox"><img src="<?php echo $image['thumb_path']; ?>" alt="<?php echo $image['file_title']; ?>"/></a></li>
            <?php endforeach; ?>
        </ul>

The hover works fine; now would like to have a black background shown on visited images, with this code:

    #galleryList {
    margin: 0;
    padding: 0 4px;
}

#galleryList li {
    display: inline-block;
    float: left;
    list-style: none;
    margin: 5px 6px;
    padding: 0;
}

#galleryList li a {
    background-color: #DF0101 !important;
    border-top: 1px solid #DF0101;
    border-left: 1px solid #DF0101;
    border-right: 1px solid #DF0101;
    border-bottom: 1px solid #DF0101;
    display: block;
    padding: 4px;
    margin-bottom: 30px;
}

#galleryList li a:hover{
    background-color: #fff !important;

}

#galleryList li a:visited {
        background-color: #000 !important;


}

But it just wont work; what am I doing wrong?

  • 写回答

2条回答 默认 最新

  • dongxie8856 2014-06-05 21:00
    关注

    Change this:

    #galleryList li a:visited {
        background-color: #000 !important;
    }
    

    to this:

    #galleryList li a:visited:hover {
        background-color: #000 !important;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献