【问题标题】:CSS / TableTools: Button background-color does not changeCSS / TableTools:按钮背景颜色不会改变
【发布时间】:2025-12-01 20:15:01
【问题描述】:

我正在将 DataTables 与 jQuery 插件 TableTools 一起使用,并希望将我自己的样式应用于那里的按钮。

在 Firebug 中检查有问题的按钮显示它们都有一个类“DTTT_button”,我对其应用了以下 CSS。

这适用于除了完全不改变的背景颜色和悬停颜色之外的所有内容。 谁能告诉我是什么原因造成的,或者我必须改变什么才能让它工作?

按钮(锚标记)在 Firebug 中的外观:

<a id="ToolTables_policyTable_0" class="DTTT_button DTTT_button_xls">
    <span>Excel</span>
</a>

我的 CSS:

.DTTT_button
{
    -moz-border-bottom-colors:none !important;
    -moz-border-left-colors:none !important;
    -moz-border-right-colors:none !important;
    -moz-border-top-colors:none !important;
    background-color:#F5F5F5 !important;
    background-image:none !important;
    border-color:#BBBBBB #BBBBBB #A2A2A2 !important;
    border-radius:4px !important;
    border-style:solid !important;
    border-width:1px !important;
    box-shadow:0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 1px 2px rgba(0, 0, 0, 0.05) !important;
    color:#333333 !important;
    cursor:pointer !important;
    display:inline-block !important;
    font-size:14px !important;
    line-height:20px !important;
    margin-bottom:0 !important;
    padding:4px 12px !important;
    text-align:center !important;
    text-shadow:0 1px 1px rgba(255, 255, 255, 0.75) !important;
    vertical-align:middle !important;
}

.DTTT_button:hover
{
    background-color:#E6E6E6 !important;
}

非常感谢您提供的任何帮助,蒂姆。

【问题讨论】:

    标签: css button datatables background-color tabletools


    【解决方案1】:

    我找到了一个解决方案,可以为我解决这个问题,并且适用于所有主要浏览器: 不需要单独的 IE9 样式,而是添加了 filter:none !important。

    【讨论】:

      【解决方案2】:

      您可以尝试使用仅限 IE9 的样式表。当 IE 格式不正确时,人们会使用它,并且他们会添加更多样式来解决问题,但这样做可能会改变其他浏览器(例如 chrome)中的外观,这就是人们使用仅 IE 样式表的原因。试试这个...

      <!--[if IE 9]>
      special event you want to happen here or link to an external stylesheet for a certain    browser
      <![endif]-->
      

      <!--[if IE 9]>
      <link rel="stylesheet" type="text/css" href="stylesheet.css">
      <![endif]-->
      

      我希望这可以帮助你。如果您需要其他帮助,请发表评论。

      【讨论】:

      • 您只需要为 IE9 添加其他样式,因此请使用仅限 IE-9 的样式表,这样当浏览器为 IE9 时,将发生特殊事件或链接。
      • 非常感谢。这听起来不错,但是如果我想更改背景颜色,我需要为 IE9 设置什么不同的样式?
      • @user2571510 谢谢。我刚刚在 IE9 中测试了代码,它运行良好并创建了一个 jsfiddle.net/LdbZJ
      • 谢谢。我找到了解决方案 - 见下文。
      【解决方案3】:

      它似乎在我的浏览器中工作,我正在使用谷歌浏览器。我不确定,但您的浏览器可能不支持 html5。请回复评论

      【讨论】:

      • 谢谢。这很有趣,它确实适用于 Chrome 和 Firefox,但不适用于 IE (9)。我正在使用也适用于我的 IE 的其他 HTML5,所以这应该是别的东西。关于如何解决这个问题的任何想法?
      • @user2571510 你好,看看我对你问题的最新回答。如果它只影响 IE9,这可能是一个不错的选择。某些样式在 IE9 中不起作用,因此请仅使用 IE9 外部 CSS
      最近更新 更多