Reputation: 6097
I have a PNG image that I'm using as an icon. It's a slightly different take on a play button. I know that when I used the font-awesome play button icon, I could do all sorts of things to that with CSS.
How do I make my png image icon stylable? Do I need to convert it to a different file?
Upvotes: 1
Views: 12983
Reputation: 9043
You can create them in a variety of programs. In Adobe Illustrator, you 'save-as' > 'svg' > note the bottom of that pane - see the svg code > copy it > past it somewhere smart.
The png is a bitmap and is just a square you can resize and turn and stuff.
<div class="image-w bitmap-logo">
<img src="http://placehold.it/400x200" alt="" />
</div>
<div class="image-w svg-logo">
<?php require('big-svg-thing.php')?>
or...
{{partial 'big-svg-thing'}}
</div>
If you use PHP or handelbars or htmlbars etc... just to keep the svg code out of your way.
With images that need to resize all the time... I put them in .image-w
to control them and to compress their pixels for retina screen.
Attached is a fiddle --- because the svg is super ugly/long code
Note that I added classes to the parts of the svg that I wanted to style
/* global / overall image styles */
.image-w img, .image-w svg {
display: block;
width: 100%;
height: auto;
}
svg path { /* good preset for svg / sets 'fill' to casdade like color */
fill: currentColor;
}
.bitmap-logo { /* things you might do with you bitmap */
max-width: 200px;
transform: rotate(10deg);
opacity: .2;
border: 2px solid red;
}
.svg-logo { /* svg */
max-width: 300px;
}
.svg-box { /* parts of the svg */
color: blue;
}
.svg-squigle {
color: red;
}
Upvotes: 1