반응형
하위 테마 CSS가 상위 항목을 재정의하지 않음
저는 어린이 테마인 2117 테마를 만들었습니다.아이의 테마 폴더에는 "style.css"와 "functions.php" 파일이 있습니다.style.css 파일 내부에는 다음이 있습니다.
/*
Theme Name: Personal_theme
Theme URI: http://wordpress:8888/
Description: This is a child theme of twentyseventeen
Author: My name
Author URI: ...
Template: twentyseventeen
Version: 0.1;
*/
.entry-title {
color: blue;
}
그리고 기능의 내부.php:
<?php
function my_theme_enqueue_styles() {
$parent_style = 'parent-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get("Version")
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>
제가 "!important!"를 스타일에 추가하면, 효과가 있고 파란색으로 변합니다.검사자 도구를 사용하면 부모 다음에 자식 스타일시트가 로드되지만 부모가 스타일을 덮어쓰는 것을 볼 수 있습니다.워드프레스에 새로 온 사람인데, 함수에 매개변수가 있습니다.php가 틀렸습니까?내가 바꿔야 할 것?
이 문제는 CSS 셀렉터 특수성 때문에 발생할 가능성이 높습니다.기본적으로 부모 CSS 규칙은 할당하는 규칙보다 해당 요소에 더 좁게 맞춤화됩니다.상위 CSS보다 더 구체적인 규칙을 사용하여 CSS를 인계받거나 나중에 로드될 때 우선 순위가 지정되는 동일한 규칙을 사용할 수 있습니다.
다음으로 기능을 업데이트해 보십시오.
<?php
function my_theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style') );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>
나중에 콘솔에 실제로 로드되고 있는 내용의 스크린샷을 제공하십시오.
부모 스타일의 변수를 만든 이유는 잘 모르겠지만 계속 사용할 수 있습니다.
이것이 도움이 되길 바랍니다.
추가 시도
@import url("..twentyseventeen/style.css");
어린이 스타일시트의 맨 위에 있는 항목 제목.템플릿 이름과 함께 입력해야 합니다.이게 도움이 되길 바랍니다.
언급URL : https://stackoverflow.com/questions/42123070/child-theme-css-not-overriding-parent
반응형
'codememo' 카테고리의 다른 글
| 파이썬으로 된 n그램, 4, 5, 6그램? (0) | 2023.06.07 |
|---|---|
| iOS 애플리케이션용 UI 레이블의 왼쪽 상단 정렬을 설정하는 방법은 무엇입니까? (0) | 2023.06.07 |
| 데이터 테이블에 새 행을 추가하는 방법 vb.net (0) | 2023.06.02 |
| 기존 테이블에 타임스탬프 추가 (0) | 2023.06.02 |
| mongo의 명령줄 인증 실패 (0) | 2023.06.02 |