如何取消.table宽度:100%在bootstrap css中

时间:2016-03-07 16:34:43

标签: css twitter-bootstrap

我希望我的桌子不占用所有可用空间。在我的bootstrap.css中,我有:

.table {
    width: 100%
...

在Chrome开发者工具中,我取消它并且表格缩小了。
如何在不修改引导程序文件的情况下在CSS文件中覆盖它 感谢

4 个答案:

答案 0 :(得分:5)

  1. 确保HTML中的 Bootstrap后包含自己的样式表。
  2. 通过在样式表中将--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-80-e47a813beced> in <module>() 1 #np.datetime64('2009') + np.timedelta64(20, 's') ----> 2 files['sent'] = files['sent'].apply(lambda x: x + np.timedelta64(files['tz_offset']), 's') /Users/myhome/anaconda/lib/python2.7/site-packages/pandas/core/series.pyc in apply(self, func, convert_dtype, args, **kwds) 2167 values = lib.map_infer(values, lib.Timestamp) 2168 -> 2169 mapped = lib.map_infer(values, f, convert=convert_dtype) 2170 if len(mapped) and isinstance(mapped[0], Series): 2171 from pandas.core.frame import DataFrame pandas/src/inference.pyx in pandas.lib.map_infer (pandas/lib.c:62578)() <ipython-input-80-e47a813beced> in <lambda>(x) 1 #np.datetime64('2009') + np.timedelta64(20, 's') ----> 2 files['sent'] = files['sent'].apply(lambda x: x + np.timedelta64(files['tz_offset']), 's') ValueError: Could not convert object to NumPy timedelta 的{​​{1}}设置为“自动”来覆盖Bootstrap的100%width样式声明:

       
    .table

答案 1 :(得分:1)

选项1

如果可以在您的Bootstrap文件之后添加CSS文件,那么这就是它所需要的:

.table {
    width: auto;
}

选项2

如果在Bootstrap文件之后无法添加CSS文件,可以像这样增加specificity

table.table {
    width: auto;
}

请注意,如果您将此代码放在Bootstrap文件之后,这也会有效。选项1稍微简单一些。

选项3(不推荐)

您还可以在规则中添加!important声明,这意味着您的规则将覆盖Bootstrap样式,无论是(1)它是在Bootstrap文件之前还是之后,以及(2)无论如何特异性:

.table {
    width: auto !important;
}

因为带有!important声明的CSS规则可以覆盖任何没有!important声明的规则,无论它们在何处定义或具有什么特殊性,具有大量{{1}的样式声明很难维护和调试。因此,建议避免使用!important,因此您应该使用选项1或选项2,具体取决于您的CSS是在Bootstrap文件之前还是之后。

答案 2 :(得分:0)

.table {
    width: initial;
}

.table {
    width: unset;
}

诀窍。

答案 3 :(得分:-1)

.table{Width :100% !important;}