【问题标题】:Class attributes not applied to a button类属性未应用于按钮
【发布时间】:2013-03-13 03:50:00
【问题描述】:

我有一个按钮,我想把它做得很大:

<button type="submit" class="button">Compra</button>

我正确(我已经有反馈)链接了一个包含此类的 CSS 文件:

.title
{
    font-size:75px;
    text-align:center;
    color:blue;
    font-family:"Times New Roman",Georgia,Serif;
}

.subtitle
{
    font-size:50px;
    font-family:"Times New Roman",Georgia,Serif;
}

.text
{
    font-size:25px;
    font-family:"Times New Roman",Georgia,Serif;
}

.table
{
    font-size:25px;
    font-family:"Times New Roman",Georgia,Serif;
    border: 0px;
    text-align: left;
    border-spacing: 20px 10px;
}

.button
{
    width:280px;
    height:280px;
}

但按钮不受按钮类大小的影响。如果我这样做:

<body>
    <form action="Purchase.xhtml" method="post">
        <button type="submit" class="button">Compra</button>
        ... (other code)

它可以工作,但我需要使用 CSS 文件,因为我有很多按钮,而且我可能想全部更改,所以在这种情况下,我只需要更改 CSS 文件。

有人知道为什么按钮类的宽度/高度属性不会影响按钮大小吗?

Jsfiddle:

http://jsfiddle.net/K2LLB/1

编辑

它适用于 Firefox,但不适用于 chrome。

【问题讨论】:

  • 似乎工作得很好 => jsfiddle.net/K2GVz
  • 你还有哪些款式?可能是重置按钮或 .button 元素的东西?包含您的完整示例的jsfiddle 会很有帮助。
  • 这就是 jsfiddle:jsfiddle.net/K2LLB
  • 它在您的演示中运行。
  • 您熟悉 Firebug 吗?如果没有,现在是时候变成这样了。

标签: css html button


【解决方案1】:

页面中的其他一些样式声明优先于 .button,无论是按特异性还是加载顺序。我们需要查看更多代码或您的演示页面才能说更多。

【讨论】:

  • 我编辑了答案。我在body标签打开后放了这个按钮,我认为没有应用其他样式。
  • 这篇文章会对你有所帮助:stackoverflow.com/questions/5876936/…(调试 CSS 覆盖)
猜你喜欢
  • 2021-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-14
  • 2021-04-04
  • 2022-08-23
  • 2019-08-06
相关资源
最近更新 更多