I'm using OceanWP Child Theme and I wanted to move all of my custom css from the template directly to the style.css file which works great, I can see on Inspect that my style.css is loaded and most of it works as well.
but there are some css lines that is not working because the original css lines is overriding my lines
for example I've tried to override this :
'@media only screen and (max-width: 480px)
.woocommerce .products.mobile-2-col .product {
width: 50% !important;
}'
with:
'@media only screen and (max-width: 480px)
.woocommerce .products.mobile-2-col .product {
width: 46% !important;
}'
And it's not working..Why? And how can I make this work without using the template custom css option?
function.php:
<?php
/**
* Child theme functions
*
* When using a child theme (see http://codex.wordpress.org/Theme_Development
* and http://codex.wordpress.org/Child_Themes), you can override certain
* functions (those wrapped in a function_exists() call) by defining them first
* in your child theme's functions.php file. The child theme's functions.php
* file is included before the parent theme's file, so the child theme
* functions would be used.
*
* Text Domain: oceanwp
* @link http://codex.wordpress.org/Plugin_API
*
*/
/**
* Load the parent style.css file
*
* @link http://codex.wordpress.org/Child_Themes
*/
function oceanwp_child_enqueue_parent_style() {
// Dynamically get version number of the parent stylesheet (lets browsers re-cache your stylesheet when you update your theme)
$theme = wp_get_theme( 'OceanWP' );
$version = $theme->get( 'Version' );
// Load the stylesheet
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'oceanwp-style' ), 1.0 );
}
add_action( 'wp_enqueue_scripts', 'oceanwp_child_enqueue_parent_style' );
// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED - Do not modify or remove comment markers above or below:
if ( !function_exists( 'chld_thm_cfg_locale_css' ) ):
function chld_thm_cfg_locale_css( $uri ){
if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) )
$uri = get_template_directory_uri() . '/rtl.css';
return $uri;
}
endif;
add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' );
// END ENQUEUE PARENT ACTION
style.css:
/*
Theme Name: OceanWP Child 02
Theme URI: https://oceanwp.org/
Template: oceanwp
Author: Nick
Author URI: https://oceanwp.org/
Description: OceanWP WordPress theme example child theme.
Version: 1.0.1611171460
Updated: 2021-01-20 19:37:40
*/
Thank you :]
question from:
https://stackoverflow.com/questions/65858928/some-of-the-child-theme-style-css-lines-is-not-working 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…