目录

data - uri

描述 (Description)

数据uri是统一资源标识符(URI)模式,它在网页中内联资源。 当没有给出MIME类型时,节点使用mime包来控制正确的MIME类型。

参数 (Parameter)

  • url - 内联文件的url。

  • mimetype - MIME类型字符串。

例子 (Example)

以下示例演示了在LESS文件中使用数据uri函数 -

misc_example.htm

<!doctype html>
   <head>
      <link rel = "stylesheet" href = "style.css" type = "text/css" />
   </head>
   <body>
      <h2>Welcome to IoWiki</h2>
   </body>
</html>

接下来,创建style.less文件。

style.less

body {
   background: data-uri('startup.jpg');
}

您可以使用以下命令将style.less文件编译为style.css -

lessc style.less style.css

执行上面的命令; 它将使用以下代码自动创建style.css文件 -

style.css

body {
   background: url('startup.jpg');
}

输出 (Output)

请按照以下步骤查看上述代码的工作原理 -

  • 将上述html代码保存在misc_example.htm文件中。

  • 在浏览器中打开此HTML文件,将显示以下输出。

减少其他功能
↑回到顶部↑
WIKI教程 @2018