html - 覆盖CSS中的显示

标签 html css twitter-bootstrap

我在 Asp.net MVC 上使用 Bootstrap 。我有一个自定义 Styles.css,我用它来设置我想要从 bootstrap.css 中的默认值更改的值。

我正在尝试为 MM YY(月年)获取两个彼此相邻的文本框。

在 Bootstrap 中它有:

display: block;

在我的 Styles.css 中,我创建了这个来覆盖那个值:

.disableblock{
  display: inline;
}

这是我的 .cshtml 中的行:

截止日期

<div class="col-sm-8">
  @Html.TextBoxFor(m => m.ExpirationDateMonth, new { @class = "form-control expirationdatetextbox disableblock", @maxlength = "2", placeholder = "MM" })
  @Html.TextBoxFor(m => m.ExpirationDateYear, new { @class = "form-control expirationdatetextbox", @maxlength = "2", placeholder = "YY" })
</div>

<div class="warning">
  @Html.ValidationMessageFor(m => m.ExpirationDateMonth)
</div>

当我在IE中显示时,显示如下:

enter image description here

如果我取消选中 display: block;,它会将两个文本框放在同一行。

为什么 Styles.css 内联不覆盖 bootstrap.css 中的 block ?d

编辑

对于那些质疑 css 调用顺序的人:

  bundles.Add(new StyleBundle("~/Content/css").Include(
    "~/Content/bootstrap.css",
    "~/Content/site.css",
    "~/Content/justified-nav.css",
    "~/Content/Styles.css")); // <-- Custom CSS file

这是来自 View 源:

<link href="/Content/bootstrap.css" rel="stylesheet"/>
<link href="/Content/site.css" rel="stylesheet"/>
<link href="/Content/justified-nav.css" rel="stylesheet"/>
<link href="/Content/Styles.css" rel="stylesheet"/>

最佳答案

尝试将 !important 放在显示值之后。如果这不起作用,请确保在加载 Bootstrap 代码时,您是在自定义 css 之前这样做的。有时,如果您首先加载自定义 css,即使您使用的是 !important,bootstrap 似乎也会覆盖。如果这有帮助,请告诉我。

关于html - 覆盖CSS中的显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43235183/

相关文章:

html - Firefox 和 Internet Explore 上的内联 block 问题

html - 使用 HTML5 推送状态 URL 为单页网站配置 nginx

CSS 旋转按钮跨浏览器,适用于 Chrome 但不适用于 firefox/safari

html - 如何减少表单水平 Bootstrap 中表单控件之间的空间?

html - 在标签前添加复选框

twitter-bootstrap - Bootstrap 4 snackbar / toast

javascript - 如何让进度条持续 20 秒?

html - 在已经安排好的表格中划分一列 HTML CSS

html - CSS Overflow-y 不滚动

css - 将鼠标悬停在图像上时使标题下划线