www.webdeveloper.com
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2009
    Posts
    79

    resolved [RESOLVED] Image next to a Division

    Hi,

    How can I put an <img> next to a <div> so the image vertically aligns in the middle?

    Code:
    <img src="http://devcentral.f5.com/weblogs/images/comment-icon.gif"><div style="font:10pt Arial;padding:5px;background-color:#ccc;"><span style="float:right">No. 1</span><span style="font-weight:bold;padding-right:10px">John Doe</span><span style="color:#808080">11/14/2010 3:23:44</span></div>
    I know how to do it using a table:

    Code:
    <table style="font:10pt Arial">
    <tr>    
    <td style="vertical-align:middle"><img src="http://devcentral.f5.com/weblogs/images/comment-icon.gif"></td>    
    <td style="width:100%">
    <div style="padding:5px;background-color:#ccc;border-top:1px solid #DEDEDE"><span style="float:right">No. 1</span><span style="font-weight:bold;padding-right:10px">John Doe</span><span style="color:#808080">11/14/2010 3:23:44</span></div>
    </td>
      </tr>
    </table>
    But I wonder if I could do it without a table.


    Thanks in advance!
    Rain Lover

  2. #2
    Join Date
    Nov 2010
    Posts
    13
    I've done it like this
    Code:
    <img src="http://devcentral.f5.com/weblogs/images/comment-icon.gif" style="float:left; padding-top: 5px;">
    <div style="font:10pt Arial;padding:5px;background-color:#ccc; margin-left:20px;">
    <span style="float:right">No. 1</span><span style="font-weight:bold;padding-right:10px">John Doe</span><span style="color:#808080">11/14/2010 3:23:44</span></div>

  3. #3
    Join Date
    May 2005
    Location
    Gold Coast (MS)
    Posts
    2,072
    Your question has already been answered here.. Might be nice to respond to answer posted.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

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
HTML5 Development Center



Recent Articles