-
Notifications
You must be signed in to change notification settings - Fork 0
Base64 Encode Function
Tommy Hodgins edited this page Sep 28, 2019
·
1 revision
A custom function that can encode any file referenced by its relative file path, and replaces it with the base64 encoded data URL to embed the data inline in CSS
--base64-encode(<path to file>)
-
<path to file>
is a relative path to the SVG file from the location of the CSS stylesheet in the filesystem
Use --base64-encode()
anywhere a file could be used in CSS to automatically convert it to url()
with the encoded file data inside.
html {
background: --base64-encode(assets/logo.png)
}
html {
background: url(data:image/png;base64, <base64 data>)
}
Note: It also works with unquoted
--base64-encode()
, single-quoted--base64-encode('')
or double-quoted--base64-encode("")
URLs