css - 在 drupal 7 中将 php 文件用于自定义 css 的困难

标签 css drupal-7 hook

我想为特定页面使用自定义 CSS。为了实现这个目标,我实现了 hook_menu 和 hook_theme。 我有一个 php 文件的链接

$url = drupal_get_path('module', 'preview_ipad') . '/css/style-css.php';
drupal_add_css($url);

在这个 php 文件中,有自定义的 css :

<?php
    header('content_type : text/css');
?>

* { padding: 0; margin: 0; }

body {
    background: url(./ret/white.png) no-repeat 50% top;
    font-family:Helvetica,Arial,Sans-serif;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    color: <?php echo $_SESSION['color'] ?>;
}

链接存在,在我页面的源代码中,但是有问题。 CSS 不起作用。

帮助

最佳答案

确保 CSS 文件最后加载。因为默认情况下 drupal 在模块的 CSS 文件之后加载主题的 CSS 文件。

尝试对此代码进行以下更改:

$url = drupal_get_path('module', 'preview_ipad') . '/css/style-css.php';
drupal_add_css($url, array(
    'group' => CSS_THEME,
    'weight' => 1000,
));

关于css - 在 drupal 7 中将 php 文件用于自定义 css 的困难,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10523784/

相关文章:

javascript - Jquery Scroll 从用户在屏幕上的任何地方滚动一个像素

css - Bootstrap 容器中的内容高度为 100%

php - drupal 7 模块不会向 Mysql 插入任何内容

java - 添加 checkstyle 作为预提交 git 钩子(Hook)

android - NativeScript:设备上是否有针对自己应用程序的 "on install"的 Hook ?

c++ - 当窗口设置为事件时获取通知

javascript - 如何: Use JQuery to fetch and update ONLY the following classes under a button living in one of those classes

html - 图像的垂直和水平中心

drupal-6 - Drupal 6 与 Drupal 7 性能对比

drupal-6 - Drupal 7 管理栏和覆盖层的 Drupal 6 向后移植?