想要通过父元素覆盖子元素css属性 [英] Want to override child element css property by parent element

查看:40
本文介绍了想要通过父元素覆盖子元素css属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<div class="parent">
    <div class="child">
</div></div>
    

在CSS中,子"类有其自己的bg颜色,我无法更改.我想申请父母"身份将bg颜色分类为容器.因此,是否有任何CSS技巧可以覆盖子"元素,bg颜色由父母"表示;背景颜色.

In CSS, "child" class has its own bg color, that I can't change. I want to apply "parent" class bg color to container. So, Is there any CSS trick to override "child" bg color by "parent" bg color.

任何帮助将不胜感激.

推荐答案

!important将覆盖应用的任何内联背景色,让我知道这是否可行

!important will override any inline background color applied, let me know if this works

.parent > .child {
    background-color: transparent !important;
 }

这篇关于想要通过父元素覆盖子元素css属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆