00 Votes

HTML: Display DIV Box between words in line in regular text flow

Question by Guest | 2014-04-14 at 18:35

On my website, I have a text in which I would like to display some small images (for example smileys) between the words but in a line. The images are all stored in one big image. This big image is displayed in parts in small DIV boxes (CSS sprites).

Now, my problem is that I cannot make the DIV boxes staying in the regular text flow. Instead, they are breaking into the next line. Has someone an idea of how to do it?

ReplyPositiveNegative
0Best Answer0 Votes

For your purpose, a DIV box is not fitting, because a DIV is not an element that is appearing in the text flow. Instead, you should get to use the SPAN-tag. It is also possible to display parts of images within this tag but it is better suitable to be shown in line.

Your CSS class can look like this for example:

.textimg {
  width: 20px;
  height: 20px;
  background: url('pic.png') -20px -20px;
  display: inline-block;
}

And in your HTML text, you can insert the image like that:

Text <span class="textimg"></span> with image.

Above all, it is important to define "display: inline-block". Apart from that, you can adjust the height, width and background like you need it. 
2014-04-16 at 18:15

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.