dstjh46606 2017-07-19 12:53
浏览 55
已采纳

Wordpress - 父主题覆盖儿童样式

I'm building a site on Wordpress using html5blank theme as a parent for first time. The majority of my style rules in the child theme are working as they should but a few aren't and I can't work out why this is the case. I've built the front-end beforehand so I know the code works in the browser. For the front-end I used reset.css and skeleton.css for my grid. I haven't transferred over the reset file as the parent theme uses normalize.css. Do I need a standalone file for my skeleton grid or can it all go into the style.css (which is what I've done) ?

For example, this is how the top of the home page should look -

Front-end version

And this is how it looks in Wordpress -

wp version

Why would certain styles apply and others not? Other than style.css and functions.php are there any other parent theme files that could influence the styling rules which I need to recreate in the child to override this? Appreciate any assistance.

UPDATE

Looking in the developer tools it is these styles from the child which are being overridden by the parent (they're struck through in developer tools)

.container {
    margin: auto;
    max-width: 100%;
    padding-left: 10px;
    padding-right: 10px;
}

.showreel {
  height: 50px;
  max-width: 100%;
  position: absolute;
  background-color: black;
  bottom: 0;
  padding: 0 30px;
  justify-content: space-between;
}

.showreel, .showreel > div.seemore {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex:1;
}
.showreel, .showreel > div.seeour {
    justify-content: flex-end;
    flex:1;
    display: flex;
    align-items: center;
}
  • 写回答

2条回答 默认 最新

  • dpafea04148 2017-07-19 13:22
    关注

    Your question is quite broad, and it is hard to give direction without having a verifiable example in front of me.

    Unfortunately, due to the nature of your problem, I am not sure if you will be able to give me a verifiable example so I am going to go ahead and point out the most obvious solution.

    Generally, in cases like this, the problem is born from Specificity in your CSS rules.

    Where you parent CSS file may initiate a rule like this:

    .menu > ul > li a { /* four selectors */
        color: #00ff00;
    }
    

    And you have a rule in your child-theme stylesheet that looks like this:

    .menu li a { /* three selectors */
        color: red;
    }
    

    In cases like this, your parent stylesheets rule will override your child stylesheets rule.

    The easiest way to check for this is to inspect the element in your browser and see how many rules are applying to your element. Generally, when a specific rule is being overridden from another place, it will have a strikethrough style in your element inspector.

    You can solve this by either:

    1. being more specific with your property declaration, or
    2. using the !important tag in your CSS
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 深度学习残差模块模型
  • ¥20 两个不同Subnet的点对点连接
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)