dou11655853 2017-07-19 19:21
浏览 262
已采纳

PHP插入时CSS不起作用

I have been trying to use PHP to insert my CSS's file contents in the style tag of a page.

<style>
    <?php 
        $css = file_get_contents('css/roboto-robotocondensed.css');
        $css .= file_get_contents('css/reset.css');
        $css .= file_get_contents('css/mainstyle.css');
        $css .= file_get_contents('css/industriaalimentosebebidas.css');
        echo $css;
    ?>
</style>

And in the last file, "industriaalimentosebebidas.css", i have the following code:

header {
    height: 500px; 
    background: url(../img/cases/casos-de-sucesso-alimentos-e-bebidas-cover.jpg) no-repeat center bottom / cover;
}

header p { 
    width: 75%;
    font-size: 1.536rem;
}
.imgGradient {
    height: 100%;
} 

@media only screen and (min-width: 1600px) {
    header {
        height: 700px;
    }
}

For some reason, the header style code above the media query is being ignored by the browser. But, when I get the CSS file using

<link rel="stylesheet" type="text/css" href="css/industriaalimentosebebidas.css"/>

everything works fine.

In the inspector, the header height does not seem to be overwritten... and background image is not being loaded.

Even if I remove the media query part, the header part does not work.

In the html head I'm using

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>

Does anyone have a clue of what might be going on?

  • 写回答

1条回答

  • dph6308 2017-07-19 19:32
    关注

    in your css look for the line:

    #infos .imgContainer{max-height:25vw}1rem}
    

    this is the reason it is broken.

    original:

    basically add spaces between the files: (not semicolons, remembered that wrong)

    <style>
    <?php 
        echo implode("
    ", [
            file_get_contents('css/roboto-robotocondensed.css'),
            file_get_contents('css/reset.css'),
            file_get_contents('css/mainstyle.css'),
            file_get_contents('css/industriaalimentosebebidas.css')
        ]);
    ?>
    </style>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器