Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将宽度属性添加到引导按钮。但是,它 <a class="btn" />的宽度与<button class="btn" />. 这是jsFiddle。
<a class="btn" />
<button class="btn" />
这是在 Chrome 中。
将左右重置padding为零会有所帮助,但会使链接按钮宽 2 像素。
padding
这是因为 chrome 的用户代理适用box-sizing: border-box于button元素,这意味着padding将包含在其中width而不是添加到其中。
box-sizing: border-box
button
width
在你的班级中设置box-sizing: content-box也修复了这个 2px 的差异。
box-sizing: content-box
见演示。