html - Bootstrap 日期选择器样式被 CSS 表格样式覆盖

标签 html css html-table bootstrap-datepicker

我的表格 CSS 代码覆盖了 Bootstrap 日期选择器。它看起来一点也不像日历。我该如何解决这个问题?

我尝试使用 css ":not"不幸的是没有用。 我不知道还能尝试什么。 我还尝试将它们更改为类,并尝试哪些效果不佳。

有没有办法只忽略此元素的 css 文件或使 bootstrap css !important?

请检查带有运行代码的演示。 谢谢。

Codepen Demo

表格的CSS代码

/*Table*/
body{
  background-color:black;
  color:white;
}

table:not(.form-control) {
    font-family: "Open Sans", sans-serif;
    border: 1px solid salmon;
    border-collapse: collapse;
    margin: 0;
    padding: 0;
    width: 100%;
    table-layout: fixed;
}

table caption {
    font-size: 1.5em;
    margin: .5em 0 .75em;
}

table tr:not(.form-control) {
    background-color: #0B0C10;
    border: 1px solid #0B0C10;
    padding: .35em;
}

table th:not(.datepicker),
table td:not(.datepicker) {
    padding: .625em;
    text-align: center;
}

table th:not(.datepicker-days) {
    font-size: .85em;
    letter-spacing: .1em;
    text-transform: uppercase;
}

@media screen and (max-width: 600px) {
    table {
        border: 0;
    }

    table caption {
        font-size: 1.3em;
    }

    table thead {
        border: none;
        clip: rect(0 0 0 0);
        height: 1px;
        margin: -1px;
        overflow: hidden;
        padding: 0;
        position: absolute;
        width: 1px;
    }

    table tr {
        border-bottom: 3px solid salmon;
        display: block;
        margin-bottom: .625em;
    }

    table td {
        border-bottom: 1px solid salmon;
        display: block;
        font-size: .8em;
        text-align: right;
    }

    table td::before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        text-transform: uppercase;
    }

    table td:last-child {
        border-bottom: 0;
    }
}

Codepen Demo

最佳答案

请查看您的 Codepen 演示的分支:https://codepen.io/kshetline/pen/mdbjyQr

您已经有了一个围绕您的表格的 table-align 类,因此所有必要的就是为 CSS 规则添加前缀,这些规则只适用于您的表格 。表格对齐。例如:

.table-align table th,
.table-align table td {
    padding: .625em;
    text-align: center;
}

.table-align table th {
    font-size: .85em;
    letter-spacing: .1em;
    text-transform: uppercase;
}

我还删除了所有 :not(.datepicker) 内容。

关于html - Bootstrap 日期选择器样式被 CSS 表格样式覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57934222/

相关文章:

html - 为 SimpleLabelStyle 定义自动换行

javascript - 如何在 Bootstrap 中使用左右箭头按钮创建图像 slider

jQuery 旋钮应用内部颜色

javascript - 数据表隐藏/显示列

css - 编辑时不调整大小的可编辑 HTML 表格单元格

javascript - 循环遍历 Object.keys 时,我的 ArrayList 显示为空

html - 专注于在 IE 中不起作用的 anchor 标记

JavaScript:修改多行输入的内容

javascript - 在HTML <区域>中使用JavaScript函数在单击时播放音频

css - 百分比宽度巨型菜单加上一个 html 列表上的标准下拉菜单