CSS 覆盖 inline style 样式

文章目录

    内联非 !important 样式

    <div class="head_b" style="height: 52px; background-color: rgb(195, 195, 195);">
    
    <style>
    div[style] {
       background: yellow !important;
    }
    </style>
    

    内联 !important 样式

    由于内联 !important 样式不可覆盖,所以只能使用 js 替换的方式来解决。

    <div class="head_b" style="height: 52px; background-color: rgb(195, 195, 195) !important;">
    
    <script>
    document.querySelector(".head_b").style.backgroundColor="#c3c3c3";
    </script>
    

    关于作者 🌱

    我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊,或者关注我的个人公众号“大象工具”, 查看更多联系方式