WordPress.org

Forums

[resolved] child theme not always overrides parent (9 posts)

  1. fprotani
    Member
    Posted 1 year ago #

    Hello everybody, I'm new to this forum.

    I decided to build my own website (http://www.protaniviolins.com) although I'm not familiar at all with html or CSS. I'm using Responsive theme and I created a child theme to customise it, as suggested by the experts in this forum.
    I'm having trouble with the front page. I've been trying to get rid of the white border at the top and bottom of the picture and to move it closer to the navigation menu. Fiddling with Chrome's Inspect element tool, I'm able to sort out the issue and place the picture where I want it to be, but when I copy and paste the CSS command with the new values into the child theme's stylesheet nothing happens. All the modified margins and paddings seem to go back to the default parent theme values. I'm clearly doing something wrong but I haven't got a clue what it could be. Any help, please?

  2. vtxyzzy
    Member
    Posted 1 year ago #

    CSS applies rules in a certain order. Normally, the last rule found is the one used. So, if your rule is not the last one found, it will have no effect unless you override the order by adding '!important' to the rule, like this:

    #featured-image {
        margin: 0 !important;
    }

    Even then, if there is another rule with '!important' that is found later that one will override yours.

  3. fprotani
    Member
    Posted 1 year ago #

    Hi vtxyzzy,
    thanks for your post. I've tried to add !important as you suggested but nothing happened.

  4. vtxyzzy
    Member
    Posted 1 year ago #

    I do not see the code when I view the site. Please leave the change in place so we can view it

  5. fprotani
    Member
    Posted 1 year ago #

    The code I'm trying to edit is this one:

    [ 406 lines of code moderated, that's just way too much. For that many lines of code please use pastebin.com instead. ]

    I hope that helps.

  6. vtxyzzy
    Member
    Posted 1 year ago #

    There is no need to post the code. Put the lines I suggested at the end of you child theme's style.css and leave them there.

  7. fprotani
    Member
    Posted 1 year ago #

    I put the code you posted at the end of the child theme's style.css but the top margin keeps going back to 40px.

  8. vtxyzzy
    Member
    Posted 1 year ago #

    I still do not see the lines at the end of the child theme's style.css. Please put them there and leave them.

  9. fprotani
    Member
    Posted 1 year ago #

    Thanks for your patience vtxyzzy. It works now and I know what I was doing wrong. I've been customising the child theme by writing codes in the Custom CSS Style section of Responsive theme options, whereas as soon as I put the code you suggested in the CSS editor it worked. What I don't understand now is why some codes worked in the Custom CSS style and some others didn't.
    Thanks a lot for your help

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags