dongzhi4239 2011-05-30 08:40
浏览 50
已采纳

我的PHP文件中的CSS

Okay, so I've been able to define the standard text color according to a database value by using this code:

<?php

echo '<div style="color: ' . $result->properties->fcolor . ';';<br />
echo 'background: ' . $result->properties->bgcolor;<br />
echo '">MY CONTENT</div>'

?>

The color that's set by

$results->properties->fcolor

works nicely, except for a:link, a:hover, a:visited, and a:active. Because it's only defining "color", the browsers default to their own link colors.

My users choose from a selection of background and font colors and Chrome's default blue link color doesn't exactly work with a dark purple background... Is it possible to set up a

<style type=text/css>

inside of my PHP file and have it reference the

$result->properties->fcolor

value that the normal part of the script pulls from my database?

This is my first big site so I'm not positive about anything but I vaguely remember enabling PHP in my external CSS file using .htaccess and it didn't successfully pull in the value of

$result->properties->fcolor

as far as I could tell.

What am I doing wrong?

Thanks in advance - amazing community here! :)

  • 写回答

3条回答 默认 最新

  • dongsashe6006 2011-05-30 08:43
    关注

    IF I'm you, I would create external css for links just to define rules not color.

    for example if your links are inside div, what you can do is just define to use color of div

    div a { color: inherit; }
    div a:HOVER { color: inherit; }
    

    so when you define your color to div through php logic your links inside div will inherit that color.

    If you experience any problems with this add important to property so color of div will be used

    div a {color: inherit !important; }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
  • ¥15 unity连接Sqlserver
  • ¥15 图中这种约束条件lingo该怎么表示出来
  • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
  • ¥15 流式socket文件传输答疑
  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接