채택완료

css 순서 질문드려요.

2023-04-03 (월) 10:31:07 1,644

head.sub.php 에 있던

Copy
<?php
if (defined('G5_IS_ADMIN')) {
    if(!defined('_THEME_PREVIEW_'))
        echo '<link rel="stylesheet" href="'.run_replace('head_css_url', G5_ADMIN_URL.'/css/admin.css?ver='.G5_CSS_VER, G5_URL).'">'.PHP_EOL;
} else {
    $shop_css = '';
    if (defined('_SHOP_')) $shop_css = '_shop';
    echo '<link rel="stylesheet" href="'.run_replace('head_css_url', G5_CSS_URL.'/'.(G5_IS_MOBILE?'mobile':'default').$shop_css.'.css?ver='.G5_CSS_VER, G5_URL).'">'.PHP_EOL;
}
?>

위 소스를 아래처럼 변경했어요. ↓↓

index 페이지에서는 common/layout/main.css 를 불러오고 이외 페이지에서는 common/layout/custom.css 를 불러올수 있도록이요.

Copy
<?php if(defined('_INDEX_')) { ?>
<link rel="stylesheet" href="<?php echo G5_CSS_URL; ?>/common.css?ver=<?php echo G5_CSS_VER; ?>">
<link rel="stylesheet" href="<?php echo G5_CSS_URL; ?>/layout.css?ver=<?php echo G5_CSS_VER; ?>">
<link rel="stylesheet" href="<?php echo G5_CSS_URL; ?>/main.css?ver=<?php echo G5_CSS_VER; ?>">
<?php } else { ?>
<link rel="stylesheet" href="<?php echo G5_CSS_URL; ?>/common.css?ver=<?php echo G5_CSS_VER; ?>">
<link rel="stylesheet" href="<?php echo G5_CSS_URL; ?>/layout.css?ver=<?php echo G5_CSS_VER; ?>">
<link rel="stylesheet" href="<?php echo G5_CSS_URL; ?>/custom.css?ver=<?php echo G5_CSS_VER; ?>">
<?php } ?>

커스텀 페이지에 아래처럼 넣었는데 reference.css 가 제일 마지막에 보여야 하는데 중간에 껴버렸습니다.

Copy
<?php
include_once('../common.php');
$g5['title'] = "커스텀 서브페이지1";
add_stylesheet('<link rel="stylesheet" href="'.G5_CSS_URL.'/reference.css">', 20);

include_once(G5_PATH.'/head.php');
?>

실제 출력 캡처

237506203_1680485407.1566.jpg

head.sub.php 내에서 common / layout / custom . css 다음으로 reference .css 가 와야하는데 왜 중간에 껴버린걸까요.

|

답변 1개

채택된 답변
+20 포인트
2023-04-03 (월) 11:05:50

일단 add_stylesheet 함수로 변경해보세요.

Copy
<?php

if(defined('_INDEX')){

    add_stylesheet('<link rel="stylesheet" href="'.G5_CSS_URL.'/common.css">', 0);

    add_stylesheet('<link rel="stylesheet" href="'.G5_CSS_URL.'/layout.css">', 0);

    add_stylesheet('<link rel="stylesheet" href="'.G5_CSS_URL.'/main.css">', 0);

}else{

    add_stylesheet('<link rel="stylesheet" href="'.G5_CSS_URL.'/common.css">', 0);

    add_stylesheet('<link rel="stylesheet" href="'.G5_CSS_URL.'/layout.css">', 0);

    add_stylesheet('<link rel="stylesheet" href="'.G5_CSS_URL.'/custom.css">', 0);

}

?>

그리고 커스텀페이지에서 add_stylesheet 순서를 변경해보세요

Copy
<?php

include_once('../common.php');

$g5['title'] = "커스텀 서브페이지1";

include_once(G5_PATH.'/head.php');

add_stylesheet('<link rel="stylesheet" href="'.G5_CSS_URL.'/reference.css">', 20);

?>

답변을 작성하려면 로그인이 필요합니다.