【问题标题】:Input submit and "a" tag styling to look identical - Firefox issue输入提交和“a”标签样式看起来相同 - Firefox 问题
【发布时间】:2023-03-30 04:50:01
【问题描述】:

我正在尝试让一个按钮(输入)和一个链接在我的页面上看起来相同,但我在 Firefox 中遇到了一些对齐问题。这是 HTML:

<p>
    <input type="submit" value="Create New User" />
    <a class="linkButton" href="/Admin">Cancel and Return to User Index</a>
</p>

我正在使用以下 CSS:

.linkButton, .linkButton:link, .linkButton:visited, input[type="submit"], input[type="button"] {
    background-color: #4AACC5;
    border: 1px solid #4A77C4;
    color: #FFFFFF;
    cursor: pointer;
    height: 27px;
    margin: 2px;
    padding: 3px 6px;
    text-align: center;
    text-decoration: none;
    width: auto;
    font: inherit;
}

通过上述设置,在 Chrome 中一切正常,但在 Firefox 中,两个元素没有对齐:

你可以用 FF 和 Chrome 来检查这个小提琴:http://jsfiddle.net/hqJDZ/5/

现在,我想要一个解决方案,在这两种情况下都不涉及使用aonclick="javascript:submit();" 之类的东西。视图是脚手架的,工作得很好,所以我更喜欢纯 HTML/CSS 解决方案。

你可能注意到我没有提到 IE...我只是暂时不想去那里:P

【问题讨论】:

  • line-height 大概?

标签: html css button


【解决方案1】:

只需在你的类中添加两个属性:

Display:block;
float:left;

【讨论】:

    【解决方案2】:

    我相信这可能是您的解决方案:https://stackoverflow.com/a/1986666/107244

    input::-moz-focus-inner /*Remove button padding in FF*/
    { 
        border: 0;
        padding: 0;
    }
    

    【讨论】:

    • 我不知道为什么,但起初这不起作用,现在它是......也许只是 v22 修复了一些东西......我至少会接受,直到它成立 :)
    猜你喜欢
    • 2015-03-12
    • 1970-01-01
    • 2022-01-20
    • 1970-01-01
    • 2013-08-19
    • 2021-01-05
    • 1970-01-01
    • 2022-01-13
    • 2018-08-10
    相关资源
    最近更新 更多