$story1 = ("<br /><br />But <u><b><span class='hint--top' data-hint='soft'>$noun1</span>
我正在尝试使用链接的 css 样式表围绕一个单词进行跨度。该类不想工作。我做错了什么?
已测试
如果这是您希望获得的预期结果,请尝试此代码。
以下内容将输出"但这是一个名词",This is a noun
下划线和浅灰色。
<?php
$noun1 = "This is a noun";
$story1 = "<br /><br />But <u><b><span class='hint--top' data-hint='soft'>$noun1</span>";
echo $story1;
?>
<style>
.hint--top {
color:#cccccc;
}
</style>
注意:我建议您关闭<u>
并<b>
标签,否则HTML的其余部分将显示为带下划线和粗体。
更改"我的"代码中的此行:
$story1 = "<br /><br />But <u><b><span class='hint--top' data-hint='soft'>$noun1</span>";
自:
$story1 = "<br /><br />But <u><b><span class='hint--top' data-hint='soft'>$noun1</span></b></u>";
如果是这样的话。我不知道你的代码是否是动态生成的。
代码上存在语法错误。您需要正确关闭报价。[修改后的代码如下]
$story1 = "<br /><br />But <u><b><span class='hint--top' data-hint='soft'>".$noun1."</span>";