【问题标题】:Bootstrap link button and button not the same width. How to fix?Bootstrap 链接按钮和按钮宽度不一样。怎么修?
【发布时间】:2012-08-09 07:28:50
【问题描述】:

我为引导按钮添加了宽度属性。但是,它并没有使<a class="btn" /> 的宽度与<button class="btn" /> 的宽度相同。这是jsFiddle

这是在 Chrome 中。

【问题讨论】:

    标签: css button twitter-bootstrap width


    【解决方案1】:

    将左右 padding 重置为零有助于但使链接按钮宽 2 像素。

    这是因为 chrome 的用户代理将box-sizing: border-box 应用于button 元素,这意味着padding 将包含在width 中,而不是添加到它之外。

    在您的班级中设置 box-sizing: content-box 也可以修复这个 2px 的差异。

    demo

    【讨论】:

    • 谢谢!但链接仍然长约 1 位。我想我会使用<button /> 版本并为其添加点击事件。
    猜你喜欢
    • 1970-01-01
    • 2014-08-31
    • 2015-04-22
    • 1970-01-01
    • 2011-10-28
    • 2020-03-27
    • 1970-01-01
    • 2012-06-18
    • 1970-01-01
    相关资源
    最近更新 更多