PHP style the title problem
i am using a tool tip plugin that works by displaying the title attribute see this
i have a image with a title:
<img class="tiptip tip_top" src="adv.jpg" height="111" width="186" title="<?php echo $first; ?>"/>
if my php looks like this, it works:
$first = 'Check out the new diggs!';
but if i use styles it doesn't:
$first = '<span style="color:#f200c8;">Check out the new diggs!</span>开发者_如何转开发';
any ideas how to use styles into php?
Your code is resulting in invalid HTML/CSS. You can't place style tags within a title attribute, only plain text. Your plugin should handle the tool tip's appearance. According to the documentation you linked to, you can modify the plugin's CSS.
Here is the HTML produced by the plugin:
<div id="tiptip_holder">
<div id="tiptip_content">
<div id="tiptip_arrow">
<div id="tiptip_arrow_inner"></div>
</div>
</div>
</div>
Those are the id's you should modify the CSS for, mainly tiptip_content
.
You can't embed styles inside of an attribute like that. You need to find the class or ID values for the actual tooltip popup and modify those. The maker of the tooltip plugin might have some documentation to help you figure out what the classes he/she used are or you might be able to use Firebug (for Firefox) or the built in Developer Tools for Chrome to help you figure out the classes/ID.
The title attribute is not a HTML box. There should be only test values. If you want to display a styled title you should display it outside a image tag, for example something like this:
<img src="file.png" <!-- some other attributes --> /><br /><?php echo $title ?>
In this case $title
can be a styled HTML text.
According to the spec, the title
attribute expects to be the "text" type. This is explained elsewhere as
text that is meant to be "human readable"
HTML markup isn't meant to be human readable (it's meant to be machine readable), so the tags are parsed as plain text.
精彩评论