Aligining multiple images on a single line with CSS

  • doraima29
  • Novice
  • Novice
  • No Avatar
  • Joined: Nov 09, 2005
  • Posts: 31
  • Loc: California
  • Status: Offline

Post April 27th, 2008, 6:30 pm

Hi,

I'm trying to align multiple thumbnails in a single line with CSS. I wonder how it is being done.

Let me write some code:

HTML

<div class="maincontainer">
<ul class="ppix">
<li caption="4 Physical Elements"><a href="../images/3dillus_4elements.jpg></li>
<li caption="Disco Poster Freak"><a href="../images/3dillus_discoposter.jpg></li>
<li caption="Intergalactic Whirlwind"><a href="../images/3dillus_whirlwind.jpg></li>
</ul>
</div>

CSS {}

I wanted to align 3 to 4 images on a single line and then the rest to flow below the first line. I have the freedom to adjust margin and padding to see how close the images are arranged. Also, wanted to include a caption below each thumbnail.

Is there a way to be done on a multiple column list instead of using multiple divs?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post April 27th, 2008, 6:30 pm

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Joined: Jul 11, 2005
  • Posts: 1828
  • Loc: In the Great White North
  • Status: Offline

Post April 27th, 2008, 8:39 pm

in your css
Code: [ Select ]
.maincontainer{
width:500px; /* something thats only wide enough for 3 images */
}

.ppix li{
float:left;
}
  1. .maincontainer{
  2. width:500px; /* something thats only wide enough for 3 images */
  3. }
  4. .ppix li{
  5. float:left;
  6. }
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com
  • neksus
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Sep 10, 2004
  • Posts: 2194
  • Loc: Canada
  • Status: Offline

Post April 27th, 2008, 8:54 pm

Assuming you have variable heights, that won't be enough because each new line can look severely messed up and not even have 3 in a line because of the float interfering.
You're either going to want to span every 3 images and float that as well, or simply put 3 images in your <li>.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 80 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.