Solved

Base64 icons

Posted on 2011-09-07
3
289 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

809 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