css - 在 CSS 中转义 url

标签 css moodle

我正在 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('&lt;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;"&gt;

您能想出任何可能的方法来解决这个问题吗?我想也许是这样的:

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/

相关文章:

android - 使用 REST Web 服务功能在 Moodle 上上传作业

git - 在 ubuntu 上安装 Moodle

javascript - 将图像和视频动态适配到 iframe 中

html - 左边的文本在容器内,图像在容器外

html - Google 字体无法在 iPhone 设备上运行

r - 使用考试包生成带有图像的 Moodle 练习

python - 通过 Python 的请求库访问 Moodle 服务器的 API

jquery - 为什么目标属性设置为 "_top"或 "_parent"在新选项卡中打开

javascript - 响应式网站 : how to keep on mobile, 默认悬停层元素 "on"

php - 登录其他网站时自动登录moodle