【问题标题】:Use different stylesheet for PHP include [closed]为 PHP 使用不同的样式表包括 [关闭]
【发布时间】:2014-12-29 07:22:44
【问题描述】:

php页面由

组成
<header>


<?php include('mid content'); ?>


<footer>

headerfooter 具有相同的 css 文件,而 mid content 具有不同的 css 文件。

我试过了:

<?php include('midcontent.php'); ?>
<style>
<?php include 'CSS/another_css.css'; ?>
</style>

但在这种情况下,footer 会被 another_css 文件覆盖

【问题讨论】:

    标签: php html css


    【解决方案1】:

    这就是 CSS 的工作原理。页面中加载的任何 CSS 文件都会应用于页面上的每个元素。如果您不希望您的 another_css.css 文件影响页脚,请使其规则特定于您想要影响的元素。

    <div id="midContent"><?php include('midcontent.php'); ?></div>
    <style>
    #midContent a { color: pink; }
    </style>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-21
      • 2011-10-10
      • 1970-01-01
      • 1970-01-01
      • 2011-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多