CSS 概述最佳实践

发布于 2025-01-04 23:15:25 字数 1431 浏览 5 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千寻… 2025-01-11 23:15:26

的确。边框外侧的矩形区域周围有一个轮廓。它不考虑圆角。

禁用轮廓没有任何问题,只需确保为使用键盘的人添加一些其他辅助功能,例如,更改焦点背景的颜色:

div {
    margin: 64px;
}

input {
    font-size: 20px;
    border-radius: 16px;
    border: 2px solid #CCC;
    padding: 2px 12px;
    outline: 0;
}

button {
    font-size: 20px;
    border-radius: 32px;
    text-transform: uppercase;
    color: #FFF;
    border: 2px solid #CCC;
    background: #CCC;
    padding: 6px 3px;
    cursor: pointer;
}
input:focus {
    border-color: #999;
}
<div>
    <input type="text" placemark="Search query..."/>
    <button>Go</button>
</div>

Indeed. An outline is around the rectangular area on the outside of the border. It doesn't take rounded corners into account.

There's nothing wrong with disabling the outline, just make sure you add some other accessibility feature for people using the keyboard, for instance, change the color of your background on focus:

div {
    margin: 64px;
}

input {
    font-size: 20px;
    border-radius: 16px;
    border: 2px solid #CCC;
    padding: 2px 12px;
    outline: 0;
}

button {
    font-size: 20px;
    border-radius: 32px;
    text-transform: uppercase;
    color: #FFF;
    border: 2px solid #CCC;
    background: #CCC;
    padding: 6px 3px;
    cursor: pointer;
}
input:focus {
    border-color: #999;
}
<div>
    <input type="text" placemark="Search query..."/>
    <button>Go</button>
</div>

昔日梦未散 2025-01-11 23:15:26

与许多表单元素一样,按钮元素在浏览器中具有不同的呈现,并且需要进行许多修复...

http://fvsch.com/code/button-css/ 应该让您在整个元素周围而不是其内容周围勾勒出按钮的轮廓。

As many form elements, the button element has different renderings in browsers, and as many fixes are needed...

http://fvsch.com/code/button-css/ from F. Verschelde should let you outline buttons around the whole element and not around its content.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文