• Hello everyone,

    I have a bit of a problem currently. On my website I have a child theme installed. In the functions.php of my child theme I import only the parent css (child css is imported by default). But in the parent theme folder ‘styles’ there is also an other responsive-style.css. The responsive-style sheet is for devices with a width of 768 px. Everything is working fine, until I try with a device under 768px. The parent responsive-style.css overwrites my responsive css I have put in the child style.css

    Anyone knows how to fix this? It would mean a lot to me, I’ve been struggling this for a couple weeks..

    Kind regards,

    Robin Buren

Viewing 7 replies - 46 through 52 (of 52 total)
  • Thread Starter robinburen

    (@robinburen)

    @kuckovic I have done that, when I test it gives this: https://gyazo.com/a43858b73c98c2ccbed59ccfb1308bce

    I need that style-responsive from the parent but in the child I have to overwrite it I think. Otherwise, when I update I have to comment out the import of the style-responsive.css in the functions.php of the parent theme.

    Kind regards,

    Robin

    @robinburen

    Yes, I understand that.
    The problem is, that your parent-theme is overriding your enqueue-function, and loading the responsive-stylesheet after your chils-theme stylesheet.

    We will fix this.
    The problem is, I do not know your theme unfortunately.
    BUT! We can try to dequeue your responsive-stylesheet, and then enqueue it again.
    In your child functions.php please comment out previous code, and add the following:

    function fix_stylesheet_problem() {
    
        wp_dequeue_style('thinkup-responsive', get_template_directory_uri() . '/styles/style-responsive.css');
        wp_enqueue_style( 'thinkup-responsive', get_template_directory_uri() . 'styles/style-responsive.css' );
        wp_enqueue_style( 'parent-style', get_stylesheet_directory_uri() . '/style.css' );
    
    }
    add_action('wp_enqueue_scripts', 'fix_stylesheet_problem');
    • This reply was modified 5 years, 1 month ago by kuckovic.
    • This reply was modified 5 years, 1 month ago by kuckovic.
    Thread Starter robinburen

    (@robinburen)

    @kuckovic I have some good news I think.

    Your method with deque en enqueue works, but I had to change it a little bit:

    My changes:

    1. this is my method now in the functions.php of the child:

    function fix_stylesheet_problem() {
    
        wp_dequeue_style('thinkup-responsive', get_template_directory_uri() . '/styles/style-responsive.css');
        wp_enqueue_style( 'thinkup-responsive', get_template_directory_uri() . '/styles/style-responsive.css' );
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    
    }
    add_action('wp_enqueue_scripts', 'fix_stylesheet_problem');

    2. I have put all of my css from the style-responsive.css to the style.css. The style-responsive in the child theme is gone now.

    Could you please take a look and confirm this before I am getting to enthusiastic

    Kind regards,

    Robin

    • This reply was modified 5 years, 1 month ago by robinburen.
    • This reply was modified 5 years, 1 month ago by robinburen.

    @robinburen

    I definitely looks like it’s not overriding anymore ??
    Works fine here ??

    Thread Starter robinburen

    (@robinburen)

    @kuckovic

    WOW, thats great to hear. I want to thank you from the bottom of my heart. There are not many people left who are really trying to help you. I really really appreciate it a lot. If I ever can do you a favor back, just let me know and i’ll be happy to help you. Thanks again for all your effort and time, you are the best. If you ever need help contact me on Skype: robinburen or Discord Robin B#3981

    I can’t thank you enough!

    Kind regards,

    Robin

    @robinburen

    I’m just glad we figured it out in the end ??
    I definitely will – and if you need any assistance again, do not hesitate to ask here, or poke me on LinkedIn (Aris Kuckovic).

    Good luck with your website adventure ??

    Best regards
    Aris Kuckovic

    Thread Starter robinburen

    (@robinburen)

    @kuckovic Yes I’m also happy about that. I have added you on LinkedIn.

    I wish you all the best with your life.

    Kind regards,

    Robin Buren

Viewing 7 replies - 46 through 52 (of 52 total)
  • The topic ‘Parent css overwrites child css responsiveness’ is closed to new replies.