SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2006
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lines of text with background colour sized to dimensions of text

    Hi there,

    I came across a tutorial some time ago which discussed the effect of having lines of text with a background colour which was automatically sized to the text content itself. Annoyingly I can't find that tutorial again but I was hoping someone on here would be able to help me.

    Instead of simply having a background colour on a block of text I would like the background to be sized to the length of the text and to automatically resize for each line. Please see the attached image for demonstration.

    blockedtextdemo.jpg

    Cheers,

    Shoxt3r

  2. #2
    SitePoint Zealot
    Join Date
    Oct 2006
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Managed to play around with some css and came up with the following, though p being an inline isn't ideal and with all the <br />'s it isn't exactly dynamic....

    Code:
    <style type="text/css">
    p{display: inline; background: #e4e4e4;}
    </style>
    <p>Lorem ipsum dolor sit amet, consectetur <br />adipiscing elit. Donec eget <br />libero magna, <br />eget ultrices</p>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •