简体   繁体   English

我的include / header.php中的参考CSS文件

[英]Reference CSS file in my includes/header.php

I have a header.php file that is called in all the pages. 我有在所有页面中调用的header.php文件。 This header file contains a menu bar. 该头文件包含一个菜单栏。 The menu bar has been modified and the new item includes opening a pop-up div on click. 菜单栏已被修改,新项目包括在单击时打开一个弹出div。 This div reference a few css and javascript files. 该div参考了一些cssjavascript文件。 How can I add these files to the header considering I cannot have a head tag in the header.php file. 考虑到header.php文件中没有head标签,如何将这些文件添加到header中。 The solution that has failed to work is: 无效的解决方案是:

<style>
<?php include '../../css/base.css'; ?>
</style>

Link to an external CSS and Javascript file, they don't need to be in the <head> section. 链接到外部CSS和Javascript文件,它们不必位于<head>部分。

To add css use 添加css使用

<link rel="stylesheet" type="text/css" href="path/to/your/css/file">

To add javascript 添加JavaScript

 <script src="path/to/your/js/file"></script>

用这个

<link rel="stylesheet" type="text/css" media="screen" href="../../css/base.css">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的 CSS 文件在我的 header.php 中不起作用? - Why isn't my CSS file working in my header.php? 将jQuery添加到Header.php文件失败 - Adding jQuery to Header.php File Fails 需要找出恶意Javascript如何注入到我的header.php Wordpress主题文件中 - Need to find out how malicious Javascript was injected into my header.php Wordpress theme file 将 Adsense 代码添加到 header.php 后,WordPress css 未加载 - WordPress css not loading after adding Adsense code into header.php 在Wordpress网站的header.php文件中找到未知代码 - Unknown code found in wordpress site's header.php file header.php中脚本的来源 - The source of a script in header.php 将Google Analytics(分析)脚本粘贴到我的网站(head.php,header.php或page-header.php)中吗? - Pasting Google Analytics Script Into My Site (head.php, header.php, or page-header.php)? 如果我的菜单在 header.php 中,如何滚动到 index.php 中的特定位置 - how to move to scroll to specific places in index.php if my menu is in header.php header.php中的WordPress,GoogleMaps和JavaScript - WordPress, GoogleMaps & JavaScript in header.php 对于响应式设计,如何为移动用户包括一个不同的header.php文件? - For responsive design, how can I include a different header.php file for mobile users?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM