我正在 moodle (arrg) 中设计一个页面,我需要对 url 进行转义,这样 moodle 就不会将其识别为 url。 我的代码:
<td style="background-image: url('http://example.com/pluginfile.php/788/mod_forum/intro/header_start.jpg');>
Moodle 识别出“链接”,因此用 <a>
包裹它标签
<td style="background-image: url('<a href=" http:="" example.com="" pluginfile.php="" 788="" mod_forum="" intro="" header_start.jpg'"="" class="_blanktarget">http://example.com/pluginfile.php/788/mod_forum/intro/header_start.jpg'); width: 55px; height: 50px;">
您能想出任何可能的方法来解决这个问题吗?我想也许是这样的:
url('ht'+'tp://example.com/pluginfile.php/788/mod_forum/intro/header_start.jpg');
但是我找不到任何关于 css 中的 url 连接的信息。
最佳答案
根据documentation ,您应该能够禁用自动链接功能,但将不应出现的部分用 ... 包装起来,因此在您的情况下:
<nolink>
<td style="background-image: url('http://example.com/blah.jpg');">
</nolink>
或者,您可以在相关代码上方添加一个样式 block 并使用类或 id,假设 moodle 知道跳过这些元素。
此外,尝试将您的标记更改为:
<td style="background-image: url(http://example.com/blah.jpg);">
双引号内的单引号可能会丢弃任何“跳过检查属性”类型的过滤器。并且您的示例代码没有 style
属性右引号,以防万一这不是错字。
关于css - 在 CSS 中转义 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22629590/