duanhan5230 2012-06-22 15:47
浏览 30
已采纳

php生成的链接样式无法正常工作

Currently this code generates a colored hyperlink to an ad listing on my site. The problem is that the text is BLACK when viewing in Firefox and Chrome. It only seems to display the colored text in IE.

Can anyone please help me to make this work properly?

<a href="<?=ProdURL($rslt["offer_adsid"])?>" style="font-size:13px;"<?=$trColor?> ><?=$Lname?></a>

update:

here's the HTML being generated. THANKS!

<a href="116-iphone-3g-8gb-as-is.htm" style="font-size:13px;"style="color:#FF0000;" >iPhone 3G 8GB AS IS</a

FIX!

I was able to fix this by finding where the value of $trColor is defined, then adding the font size style tag to be included along with the color style tag. Fixed now, thanks guys!

  • 写回答

3条回答 默认 最新

  • douerlin4366 2012-06-22 15:50
    关注

    Thanks for giving the exact HTML output. I see two potential problems:

    1. There is no space before the second style= element. I'm guessing IE interprets this okay anyway, and the other browsers treat it as garbage and ignore it.

    2. I'm not sure if there's an agreed-upon standard among the different mainline browsers of what to do when there are multiple style="..." attributes on a single HTML element. I haven't tried it, but immediate questions that come to my mind are: Should they be additive? Or should one of them overrule the other one? I've always known the "correct" method to be combining all CSS directives into one style="..." attribute, which you could easily do here.

    I would make $trColor be just the hexadecimal color code, and rewrite the HTML like this:

    style="font-size:13px;color:<?php echo $trColor ?>"
    

    So that your HTML is rendered like so:

    <a href="116-iphone-3g-8gb-as-is.htm" style="font-size:13px;color:#FF0000">iPhone 3G 8GB AS IS</a>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度