+ Reply to Thread
Results 1 to 4 of 4

Thread: Aligning text + Images together

  1. #1
    Awesomexr's Avatar
    Awesomexr is offline x10 Sophmore Awesomexr is an unknown quantity at this point
    Join Date
    Dec 2008
    Location
    haslam.pcriot.com
    Posts
    118

    Aligning text + Images together

    Just to make it easier to explain, i quickly made a picture:



    So any ideas on how to create that in HTML/CSS?

  2. #2
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: Aligning text + Images together

    Use the "float: left" property in CSS for each element. Put all the image text inside a containing div and right before the end of the div, add
    HTML Code:
    <div style="clear: both;"> </div>
    Overall code:
    HTML Code:
    <div id="container">
        <img style="float: left;" ... />
        <div style="float:left; max-width: ??;" ...>Blah Blah Blah Blah Blah Blah</div>
        <img style="float: left;" ... />
        <div style="float:left; max-width: ??;" ...>Blah Blah Blah Blah Blah Blah</div>
        <div style="clear: both;"> </div>
    </div>
    Last edited by xav0989; 12-12-2009 at 10:08 AM.
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  3. #3
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Aligning text + Images together

    What behavior do you want if there isn't enough horizontal space for all the items?

    To add a little to xav0989's answer, use classes, rather than inline styling, to associate a style to the elements. Make the names descriptive of what the elements are, rather than how they're styled (e.g. don't use the class "left").
    Style:
    Code:
    ul.profiles, ul.profiles li {
        margin: 0;
        padding: 0;
        list-style-type: none;
        overflow: auto;
    }
    
    .profiles li, .profiles li img, .profiles li .blurb {
        float: left;
    }
    
    .profiles li .blurb {
        max-width: ...;
    }
    Structure:
    HTML Code:
    <ul class='profiles'>
        <li><img src="http://forums.x10hosting.com/programming-help/programming-help/..." /><div class="blurb">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</div></li>
        <li><img src="http://forums.x10hosting.com/programming-help/programming-help/..." /><div class="blurb">Donec fermentum orci nec felis.</div></li>
        <li><img src="http://forums.x10hosting.com/programming-help/programming-help/..." /><div class="blurb">Sed sollicitudin diam id sapien.</div></li>
    </ul>
    If you want the text to flow underneath the pictures, get rid of the .blurb elements.
    Last edited by misson; 12-12-2009 at 04:52 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  4. #4
    Awesomexr's Avatar
    Awesomexr is offline x10 Sophmore Awesomexr is an unknown quantity at this point
    Join Date
    Dec 2008
    Location
    haslam.pcriot.com
    Posts
    118

    Re: Aligning text + Images together

    Thank you so much!

+ Reply to Thread

Similar Threads

  1. html/css help
    By swantonbomb88 in forum Programming Help
    Replies: 3
    Last Post: 05-01-2008, 09:12 AM
  2. BB Code Guide
    By Jober68 in forum Tutorials
    Replies: 1
    Last Post: 01-10-2008, 05:12 PM
  3. What is Authentication
    By asadislam78 in forum Computers & Technology
    Replies: 1
    Last Post: 12-13-2007, 07:13 AM
  4. Replies: 5
    Last Post: 11-26-2006, 12:58 AM
  5. Random Images And text
    By ak007 in forum Tutorials
    Replies: 9
    Last Post: 11-21-2005, 02:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers