【问题标题】:change CSS style更改 CSS 样式
【发布时间】:2020-08-18 00:57:39
【问题描述】:

我有一个由主 CSS 样式文件生成的元素。 HTML部分是:

<div class="footerLine"></div>

开发者工具中的样式显示:

@media (min-width: 1919px)
.footer .footerLine {
    background: url(footer.png) no-repeat 35px bottom;
    background-size: auto 86px;
    width: 100%;
    height: 250px;
}

在开发人员工具中更改 height 实际上会按我的意愿更改高度,但是当更改 CSS 本身的高度时,没有任何反应,所以我认为我做错了什么。

我想做的是:

@media screen and (min-width: 1919px)
{
   .footerLine
   {
       height:  50px;
   }
}

我什至在没有 media screen 的情况下尝试过,但也没有成功。

【问题讨论】:

  • 这是一种来自其他样式表的样式,如果您想使用您的样式,请使用更具体的选择器,或者您可以使用 height: 50px !important
  • 我尝试过使用!important。它没有工作
  • 硬刷新

标签: html css angular


【解决方案1】:

有 css 层次结构,当你在一个选择器中使用 2 个类,在另一个选择器中使用 1 个类(但针对同一元素),那么这个有 2 个类的选择器更强。

更多信息在这里:https://specificity.keegan.st/

你需要写:

@media screen and (min-width: 1919px){
  .footer .footerLine {
    background: url(footer.png) no-repeat 35px bottom;
    background-size: auto 86px;
    width: 100%;
    height: 250px;
}

然后:

@media screen and (min-width: 1919px){
  .footer .footerLine {
    height: 50px;
  }
}

【讨论】:

  • 都在同一个css文件中?
猜你喜欢
  • 1970-01-01
  • 2015-02-02
  • 1970-01-01
  • 2013-07-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多