css - HTML - 优先使用 CSS 样式

标签 css

我有一个加载两个样式表的 HTML:

  1. Bootstrap 样式 (bootstrap.css)
  2. 自定义应用样式(site.css)

我在 bootstrap.css 中有以下代码

.modal-open .modal {
    overflow-x: hidden;
    overflow-y: auto;
}

我需要在我的 site.css 中插入什么,所以我优先使用 site.css 样式而不修改 bootstrap.css:

.modal-open .modal {
    overflow-x: hidden;
    overflow-y: scroll;
    background-color: #D5D5D5
}

最佳答案

而不是添加 !important ,您可以在 <head> 中的 Bootstrap 样式表之后添加自定义样式表。您网站的部分:

<link href="bootstrap.css" rel="stylesheet">
<link href="site.css" rel="stylesheet">

这样,对于任何重复的 CSS 选择器/属性,site.css将覆盖 bootstrap.css

关于css - HTML - 优先使用 CSS 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40965901/

相关文章:

css - 底部文本对齐或菜单

Javascript 无法在新的引导站点上运行

jquery - 工具提示超出屏幕

html - 有人可以详细解释 clear 在此代码中的工作原理吗?

html - 如何将一个背景图像设置为每个帖子都设置在 tumblr 主题上的框?

html - 当它是 "overflowing"容器时垂直渲染元素并向左浮动

具有无/零值的 CSS 规则

css - 如何使用 Chrome Workspaces 保存使用 Angular2 + webpack 在本地更改的 CSS?

javascript - 此返回窗口无法运行 javascript

Jquery 在页面加载/调整大小时调整 div 的大小