在MDN的文档中css``content
:
/* <uri> value */
content: url(http://www.example.com/test.html);
题:
可以在元素的css
content
属性下html
以的url()
值显示图像content
.content {
content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAScAAADBCAYAAACNMHZqAAAABHNCSVQICAgIfAhkiAAAApJJREFUeJzt1DEBwCAQwMCnynEOBrqT4U5BpqzZcwYg5nsdAPDHnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUi6PDoDAbyCsn8AAAAASUVORK5CYII=);
}
<div class="content"></div>
或content
在伪元素上使用属性,例如::before
.content::before {
content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAScAAADBCAYAAACNMHZqAAAABHNCSVQICAgIfAhkiAAAApJJREFUeJzt1DEBwCAQwMCnynEOBrqT4U5BpqzZcwYg5nsdAPDHnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUi6PDoDAbyCsn8AAAAASUVORK5CYII=);
}
<div class="content"></div>
是否可以渲染.html
文档,.html
元素位于css
content
?
.content {
content: url(data:text/html,abc);
}
<div class="content"></div>
另请参阅CSS生成的内容模块级别3
该content
属性指示在元素或伪元素内部呈现的内容。它需要用逗号分隔的URI列表,然后是用空格分隔的令牌列表。如果提供了多个URI,则依次尝试每个URI,直到找到一个既可用又受支持的值。如果其他值失败,则最后一个值用作备用。
实施例4
h1 { content: url(header/mng), url(header/png), none; }
在上面的示例中,如果header/mng
不是受支持的格式,则将header/png
使用该格式。在上面的示例中,如果header/png
也不可用,则该<h1>
元素将为空,因为最后一个选择是none。
要使元素在其内容上进行后备,必须显式地将内容作为后备:
实施例5
content: url(1), url(2), url(3), contents;
问题3如果不支持任何格式,并且作者没有明确表示后退,该怎么办?
问题4除非作者明确声明,否则元素为何不退回内容?
更新资料
在此,最远的人员能够将html
文档嵌入并显示在css
生成的内容中;使用@LGSon演示的方法。包括css
生成中的内容html
,在svg
为好。
如@ RokoC.Buljan所述,MIME类型不是"text/html"
。
content {
content: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJ5ZXMiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MDBweCIgaGVpZ2h0PSI0MDBweCIgdmlld0JveD0iMCAwIDQwMCAzMDAiPgogICAgPGZvcmVpZ25PYmplY3Qgd2lkdGg9IjQwMHB4IiBoZWlnaHQ9IjMwMHB4IiAKICAgICByZXF1aXJlZEZlYXR1cmVzPSJodHRwOi8vd3d3LnczLm9yZy9UUi9TVkcxMS9mZWF0dXJlI0V4dGVuc2liaWxpdHkiPgogICAgICA8aHRtbCB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCI+PGhlYWQ+PHN0eWxlIHR5cGU9InRleHQvY3NzIj5jb250ZW50e2NvbnRlbnQ6dXJsKCJkYXRhOmltYWdlL3BuZztiYXNlNjQsaVZCT1J3MEtHZ29BQUFBTlNVaEVVZ0FBQVNjQUFBRERDQVlBQUFEQStOZGhBQUFBQkhOQ1NWUUlDQWdJZkFoa2lBQUFBcGxKUkVGVWVKenQxQ0VCQUNBQXdEQ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khNQ2tzd0pTREluSU1tY2dDUnpBcExNQ1VneUp5REpuSUFrY3dLU3pBbElNaWNneVp5QUpITUNrc3dKU0RJbklNbWNnQ1J6QXBMTUNVZ3lKeURKbklBa2N3S1N6QWxJTWljZ3laeUFKSE1Da3N3SlNESW5JTW1jZ0NSekFwTE1DVWd5SnlESm5JQWtjd0tTekFsSU1pY2d5WnlBSkhNQ2tzd0pTREluSU1tY2dDUnpBcExNQ1VneUp5REpuSUFrY3dLU3pBbElNaWNneVp5QUpITUNrc3dKU0RJbklNbWNnQ1J6QXBMTUNVZ3lKeURKbklBa2N3S1N6QWxJTWljZ3laeUFKSE1Da3N3SlNESW5JTW1jZ0NSekFwTE1DVWd5SnlESm5JQWtjd0tTekFsSU1pY2d5WnlBSkhNQ2tzd0pTREluSU1tY2dDUnpBcExNQ1VpNlBEb0RBYnlDc244QUFBQUFTVVZPUks1Q1lJST0pIj48aDE+VGV4dCBnb2VzIGhlcmU8L2gxPjxpbWcgc3JjPSJncmVlbi5wbmciPjwvaW1nPjxkaWFsb2cgc3R5bGU9InRvcDoxNTBweDsiIG9wZW49InRydWUiPmNvbnRlbnQ8L2RpYWxvZz48Y29udGVudD48L2NvbnRlbnQ+PC9ib2R5PjwvaHRtbD4KICAgIDwvZm9yZWlnbk9iamVjdD4KPC9zdmc+Cg==)
}
<content></content>
<?xml version="1.0" standalone="yes"?>
<svg xmlns="http://www.w3.org/2000/svg" width="400px" height="400px" viewBox="0 0 400 300">
<foreignObject width="400px" height="300px"
requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
<html xmlns="http://www.w3.org/1999/xhtml"><head><style type="text/css">content{content:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAScAAADDCAYAAADA+NdhAAAABHNCSVQICAgIfAhkiAAAAplJREFUeJzt1CEBACAAwDCgfw1yQgE8F1uCq8+zxxkAMet3AMCLOQFJ5gQkmROQZE5AkjkBSeYEJJkTkGROQJI5AUnmBCSZE5BkTkCSOQFJ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gyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUgyJyDJnIAkcwKSzAlIMicgyZyAJHMCkswJSDInIMmcgCRzApLMCUi6PDoDAbyCsn8AAAAASUVORK5CYII=)"><h1>Text goes here</h1><img src="green.png"></img><dialog style="top:150px;" open="true">content</dialog><content></content></body></html>
</foreignObject>
</svg>
内容,3.4。资源定位符:<url>
类型
MDN( 错误? )指出这是可能的
…
< uri>值
内容:url;
o_O可能是对建议书规范的错误解释,通常是 URL (限于某些MIME类型)和 URI 之间的基本区别。
虽然你可以在看到AJAX完美地完成这项工作,
而content: url(someValidHTMLUri.html)
不是做工作text/[html,...]
,而不是MIME类型的内容进行编码,传输类application/
,image/
…
http://jsbin.com/zozetaj/1/edit?html,css,js,output
该值是一个URI,用于指定外部资源(例如图像)。如果用户代理无法显示资源,则它必须像未指定资源一样将其丢弃,或者显示一些无法显示资源的指示。
问题内容: 只是想知道是否有可能以某种方式使CSS属性插入html代码而不是在上插入字符串或类似这样的元素: 这将非常方便…可以通过Javascript完成,但是使用CSS确实可以使生活更轻松:) 问题答案: 不幸的是,这是不可能的。根据规格: 生成的内容不会更改文档树。特别是,它不会反馈到文档语言处理器(例如,用于重新解析)。 换句话说,对于字符串值,这意味着始终按字面意义对待该值。无论使用哪种
有很多这样的词:test1test2test3test4test5test6test7test8test9test10test11。。。 每个单词都与多个例句相关联。我希望它们在光标覆盖单词之前被隐藏。这是我的代码。 演示:https://jsfiddle.net/kyubyong/umxf19vo/ HTML: CSS 问题是,当原始行不止一行时,例句块覆盖了底线中的单词。我想把它们写下来,这样
问题内容: 是否可以使用html5按钮事件运行bat /可执行文件?在IE中,如果我没有记错的话,可以使用Shell对象来实现。 问题答案: 这就是我所做的。我希望在我们的网络上设置HTML页面,这样就不必导航到各个文件夹来安装或升级我们的应用程序。因此,我要做的是在每个人都可以访问的“共享”驱动器上设置一个.bat文件,在该.bat文件中,我有以下代码: HTML代码是: (确保您的斜杠正确无误
问题内容: 如何在同一页面中显示XML和其他类型的数据? 上面的XML应该按格式显示。另外,我想在页面中显示HTML表和其他内容。如何实现呢? 我确实在STRING中通过文件获取了XML。 我不想解析它 我要显示(就是这样) 如果您谈到XSLT(请举个例子) 我正在考虑使用Jquery插件(有任何示例吗?) 问题答案: 一种简单的解决方案是将其嵌入元素内,这样既可以保留格式,也可以保留尖括号。我还
我写了一个游戏java脚本代码,我需要用超文本标记语言显示分数变量。我尝试它,但它总是打印0,而不是增加分数。分数变量递增1,但在超文本标记语言页面上,它保持显示0。在哪里我应该改变标签以正确显示它,还是我需要改变它java脚本得分功能? 我的Java脚本代码: HTML代码:
我试图使用伪元素插入