javascript - 按钮的背景颜色不会通过 Tab 键选择而改变

标签 javascript html css

当我通过鼠标指针悬停在按钮上时,背景颜色会发生变化,但通过 Tab 键背景颜色不会改变。

在 html 中

<style>
    .btn-primary {
        color: #fff;
        background-color: #227ab9;  
        border: none;
        cursor: pointer;
    }
    .BtnStyle {
        text-transform: uppercase;
        font-weight: 700;
        border-radius: 4px;
    }
    .btn-primary:hover,.btn-primary:focus,.btn-primary:active{
        background-color: #1a5e8e;

    }
</style>    

<table>
    <td><input id="txt" class="" type="text" value=""></td>
    <td id="go" class="BtnStyle btn-primary" >
        <button class="btn-primary"><i class="fa fa-chevron-save" aria-hidden="true"></i>test</button>
    </td>
</table>

最佳答案

<style>
    .btn-primary {
        color: #fff;
        background-color: #227ab9;  
        border: none;
        cursor: pointer;
    }
    .BtnStyle {
        text-transform: uppercase;
        font-weight: 700;
        border-radius: 4px;
    }
    .btn-primary:hover,.btn-primary:focus,.btn-primary:active{
        background-color: #1a5e8e;

    }
</style>    

<table>
    <td><input id="txt" class="" type="text" value=""></td>
    <td id="go" class="BtnStyle btn-primary" >
        <button class="btn-primary"><i class="fa fa-chevron-save" aria-hidden="true"></i>test</button>
    </td>
</table>

关于javascript - 按钮的背景颜色不会通过 Tab 键选择而改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31333993/

相关文章:

javascript - 视差滚动与 JQuery 动画绊倒

javascript - 使用 JS/jQuery 剥离字母和符号的粘贴内容?

javascript - 传递关联数组作为 Prop 不起作用

javascript - HTML:无法使用 Tab 键访问链接

javascript - Vanilla Javascript 单击包含特定文本的 LI

jquery - 使用 data() 和 attr() 选择和调用原始 css 在 Firefox 中有效,但在 Opera 和 Chrome 中无效?

javascript - AngularJS UI-router 从客户端状态更改父模板 url

javascript - ol.Overlay 在 IE 和 Firefox 上滚动 map

html - 自举列重叠

javascript - 如何消除这个 JQuery/CSS3 动画的闪烁