Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Add image to left of text via css
#1

How can I add an image to some text via css?
I've got this:
Code:
<span class="create">Create something</span>
and I want to add a 16x16 image to the left of that by using css. Is this possible or should i just manually add this image like so:
Code:
<span class="create"><img src="somewhere"/>Create something</span>
I'd rather not have to manually change all of the places which is why I wanted to do it via css.
thanks!
Reply
#2

Try Something like this:

Code:
.create{
background-image: url('somewhere.jpg');
background-repeat: no-repeat;
padding-left: 30px;  /* width of the image plus a little extra padding */
display: block;  /* may not need this, but I've found I do */
}

You might have to play around with padding and possibly margin until you get your desired result.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)