Solved

Base64 icons

Posted on 2011-09-07
3
291 Views
Last Modified: 2013-09-15
Hello,
    I am using sencha touch in a project.  I have encoded some icons in the css using Base64. The resulting icon classes work great in sencha touch. The problem is I would like to reuse some the icons using good ole html and css. I have seen examples like this that uses Base64.

<img alt="Embedded Image"
  src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..." />

the problem is my icons are already setup as a class for sencha touch. like so..

       .favsIcon {-webkit-mask-box-image:url(data:image/png;base64,iVBORw0K....
}

How do I call this class to display the icon in html? or even as a background image of another class? I want to avoid having to use the icon file if I don't have to.

Thanks
0
Comment
Question by:JohnBran
3 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 36500219
You can declare an "icon" class-ex:

.icon {
  width:100px;
  height:100px;
  background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA...);
}

Then to use it, you just assign that class to the element:
<div class="icon">...</div>

An element can have multiple classes. You just need to separate them with a space. Thus, you can "reuse" your "icon" class definition:
<div class="someClass someOtherClass icon">...</div>

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question