Skip to content Skip to sidebar Skip to footer

Show Text On Image Background

I am trying to do something new for my project. I have an icon, lets say kind of like Mail icon. When a page is loaded, the icon also gets rendered. Based on a query count I do in

Solution 1:

Despite being answered and accepted, just wanted to share how this could be done as I did it before in one of my projects. Putting it here as a code reference.

HTML:

<a href="#" class="icon" >
    <span class="jewel">2</span>
</a>

CSS:

.icon {
    position: relative;
    display: inline-block;
    height: 24px;
    padding: 0px 4px 0px 20px;
    background: ....;
}

.jewel {
    position: absolute; 
    display: block; 
    top: -8px; right: -8px; 
    height: 16px; width: 16px; 
    text-align: center; 
    color: White; 
    background-color: Red; 
    overflow: hidden; 
}

Working fiddle: http://jsfiddle.net/gE3hz/


Solution 2:

I would recommend making the icon image the background of a div or so, then you can place the number on top of it as plain text, moving it around using padding.


Post a Comment for "Show Text On Image Background"