【问题标题】:when i clicked on button the border color change default in black color in html and css当我单击按钮时,边框颜色在 html 和 css 中默认更改为黑色
【发布时间】:2022-01-12 07:15:31
【问题描述】:

当我单击该按钮时我使用了两个按钮 应该使用 javascript 更改 div 替换功能问题是当我单击按钮时默认更改边框为黑色 我找不到添加的位置我正在添加屏幕截图。它发生在我添加点击替换功能

<script>
        function replace(hide, show) {
            document.getElementById(hide).style.display = "none";
            document.getElementById(show).style.display = "block";
        }
    </script>
     <div class="two_btn">
            <div class="order_btn">
                <button type="button"  onclick="replace('div2','div1')">Order & Collect</button>
            </div>
            <div class="book_collection">
                <button type="button" onclick="replace('div1','div2')">Book UK Collection</button>
            </div>
        </div>

【问题讨论】:

  • 尝试按钮{outline:none}
  • @Minal Chauhan 不工作
  • 请添加css代码...
  • @Minal Chauhan,完成了。我正在添加这种样式,我现在可以使用内联样式了

标签: javascript html css


【解决方案1】:

这是一个焦点轮廓,由您的浏览器自动添加。要完全删除它(不建议),您可以将其添加到您的 CSS:

button:focus {
  outline: none;
}

为什么你不应该这样做而使用不同的方法:

https://www.a11yproject.com/posts/never-remove-css-outlines/

http://www.outlinenone.com/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-12
    • 2020-12-17
    • 2017-09-05
    • 2012-03-29
    • 1970-01-01
    • 2021-04-23
    • 1970-01-01
    相关资源
    最近更新 更多