CSS 覆盖需要帮助

问题描述 投票:0回答:1

我在 CSS 文档中有以下代码,该代码已被锁定,因此我无法更改它。加载了另一个可更改的 CSS 文档,我用它来覆盖同一个锁定文档中的其他 CSS 元素,但它对 {} 中的项目使用 !important。

`@media only screen and (max-width: 800px) {
  .people-grid ul li {
    width: calc(50% - var(--cell-margin));
    padding-bottom: 50px;
  }
  .people-grid ul li:first-child, .people-grid ul li:nth-child(2), .people-grid ul li:nth-child(3) {
    width: calc(100% - var(--cell-margin));
  }
}
`

我需要做什么: 我不需要 .people-grid ul li:nth-child(3) 样式像 .people-grid ul li:first-child, .people-grid ul li:nth-child(2)

或者换句话说(如果我可以改变这个实际的 CSS 文件)我想删除 .people-grid ul li:nth-child(3)

提前致谢...

我尝试了以下方法,但没有成功。

`@media only screen and (max-width: 800px) {
  .people-grid ul li {
    width: calc(50% - var(--cell-margin));
    padding-bottom: 50px;
  }
    .people-grid ul li:nth-child(3) {
    width: calc(50% - var(--cell-margin)) !important;
    padding-bottom: 50px !important;
  }
}`

不起作用

`@media only screen and (max-width: 800px) {
  .people-grid ul li {
    width: calc(50% - var(--cell-margin));
    padding-bottom: 50px;
  }
    
  .people-grid ul li:first-child, .people-grid ul li:nth-child(2) { 
    width: calc(100% - var(--cell-margin)); !important;
  }
}
`

不起作用

`@media only screen and (max-width: 800px) {
  .people-grid ul li {
    width: calc(50% - var(--cell-margin));
    padding-bottom: 50px;
  }
    
  .people-grid ul li:first-child, .people-grid ul li:nth-child(2) { 
    width: calc(100% - var(--cell-margin)); !important;
  }
.people-grid ul li:nth-child(3){
    width: calc(50% - var(--cell-margin)) !important;
    padding-bottom: 50px !important;
  }
}`

不起作用

html css stylesheet
1个回答
0
投票

没关系,我已经弄清楚了。只是不够细心。

这是可行的解决方案。

@media only screen and (max-width: 800px) {
  .people-grid ul li {
    width: calc(50% - var(--cell-margin));
    padding-bottom: 50px;
  }
    
  .people-grid ul li:first-child, .people-grid ul li:nth-child(2) { 
    width: calc(100% - var(--cell-margin)) !important;
  }
.people-grid ul li:nth-child(3){
    width: calc(50% - var(--cell-margin)) !important;
    padding-bottom: 50px !important;
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.