Solved

Base64 icons

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now