SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2011
    Posts
    418
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Centre text in relation to image horizontally

    Hi,

    Is there a way to style text in the centre horizontally next to an image? If the image covers an odd number of lines the text can be centred. If an even number, it cannot. I need a simple way to have text appear next to an image centred.

    Image Here Covering Line 1
    Image Here Covering Line 2
    Image Here Covering Line 3 Text appears in centre horizontally
    Image Here Covering Line 4
    Image Here Covering Line 5




    Image Here Covering Line 1
    Image Here Covering Line 2
    Image Here Covering Line 3 Text does not appear in centre horizontally
    Image Here Covering Line 4


    Any ideas,

    Matthew.

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,621
    Mentioned
    413 Post(s)
    Tagged
    7 Thread(s)
    You can do something like this:

    HTML
    Code:
    <p><img src="image.gif">This is the text</p>
    CSS
    Code:
    p img {vertical-align: middle;}

  3. #3
    SitePoint Evangelist
    Join Date
    Mar 2011
    Posts
    418
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes - this works well. Thanks for your help Ralph M.

    Matt.


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
  •