代码之家  ›  专栏  ›  技术社区  ›  Zeeshan Adil

将焦点状态的CSS颜色移除为当前颜色

  •  0
  • Zeeshan Adil  · 技术社区  · 7 年前

    我有一些 anchor 根据分配给它们的类获得动态颜色的标记,但在焦点上,它们获得白色原因 bootstrap overrides .

    现在我只需要用这个类重写锚点的默认引导样式,比如 a.custom-label 和另一个泛型类来获取 原色(聚焦前) 像这样专注:

    a.custom-label:focus {
        color: unset;
        color: initial;
        color: revert;
        color: inherit;
        color: none;
    }
    

    我试过这些,但似乎没有什么效果,有人能分享一种方法来达到这个目的吗?

    3 回复  |  直到 7 年前
        1
  •  0
  •   Gopal Garva    7 年前
    a.custom-label:focus { color: #000 !important; }
    

    你可以改变你想要的颜色来代替000。如果你不想使用的话!重要信息,然后添加外部CSS并在头块中的引导CSS下面调用它。

        2
  •  0
  •   Raktim Kashyap    7 年前

    试着放“!重要提示“在颜色名称之后 例如:

    a.custom-label:focus {
        color: #2d2d2d !important; }
    
        3
  •  0
  •   Zeeshan Adil    7 年前

    最好的方法是从HTML元素中删除默认的引导标签类,并在引导中为 .label 类并用选择器将其粘贴到my custom.css中 .custom-label 除了焦点造型 这样地:

    .custom-label {
        display: inline;
        padding: .2em .6em .3em;
        font-size: 75%;
        font-weight: 700;
        line-height: 1;
        color: #fff;
        text-align: center;
        white-space: nowrap;
        vertical-align: baseline;
        border-radius: .25em;
    }
    

    只对我的所有元素使用这个类。

    这将提供引导的所有默认样式,但不作为 onfocus 被粘贴,所以问题得到了解决。