• halcyonweb

    (@halcyonweb)


    Why does main.css override my child theme’s style.css? The problem I am having is a second level menu item is not accessible due to top being set to 4em for .main-navigation ul ul. I have the following code in my child theme’s style.css (and this fixes the menu problem, but is over written by main.css

    .main-navigation ul ul {
      top: 3em;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • vijayrajesh

    (@vijayrajesh)

    Hi,

    Create functions.php in your child theme. Inside that add these code

    <?php
    	function call_my_class()
    	{
    	 wp_enqueue_style( 'child-main', get_stylesheet_directory_uri()."/child-style.css" );
    	}
    
    	add_action( 'wp_enqueue_scripts', 'call_my_class',999);
    ?>

    Then, create a file named “child-style.css” in your child theme. So, in future any style created inside child-style.css will help you override main.css styles from the child theme.

    Thread Starter halcyonweb

    (@halcyonweb)

    Thanks Vijay, that’s done the trick!

    Hi Vijay.
    I created a “sixteen-child” theme folder in my themes folder, activated it and in it put custom footer.php, home.php and style.css files. The footer and home pages are working fine, but the css file is not being invoked. I tried creating a functions.php file but it doesn’t work. Help! Here’s the code:
    <?php
    function call_my_class()
    {
    wp_enqueue_style( ‘child-main’, get_stylesheet_directory_uri().”../style.css” );
    }

    add_action( ‘wp_enqueue_scripts’, ‘call_my_class’,999);
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Main.css overrides child theme style.css?’ is closed to new replies.