Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 04-28-2008, 04:58 AM   #1 (permalink)
wolf99
Code Monkey
 
wolf99's Avatar
 
Join Date: Jan 2006
Location: in college (again) in rural Eire
Posts: 45
wolf99 is on a distinguished road
some trouble with CSS aligning text

Hi All

im not too experienced with CSS, and have a small prob

I have a floating div that holds a set of images. I want to use the CSS to place a little bit of info about each set of images beside the set then there is anther set further on like-wise.

eg.

DivA
image blahblah blah blah
image blah blahblah
image etc
image

DivB
image blahblah blah blah
image blah blahblah
image etc
image

Ive read so many different and sometimes contradictory methods I am thoroughly confused as to the correct way to do this

thanks for any help
wolf99 is offline   Reply With Quote
Old 05-01-2008, 09:12 PM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
I like to use nested lists for this sort of thing.
So you have an unorderd list of unordered lists that each contain an image a desciption and whatever else you want. You can set up the inner list class to render horizontally.

Of course, the more cynical might state that that's a table and you could just make each div contain a table and use the CSS for style not layout (since the data itself is semantically tabular, it shouldn't set off the anti-table nazis).
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 05-17-2008, 08:20 AM   #3 (permalink)
wolf99
Code Monkey
 
wolf99's Avatar
 
Join Date: Jan 2006
Location: in college (again) in rural Eire
Posts: 45
wolf99 is on a distinguished road
hmm

hmmm thanks technomage, hadn't event thought of tabular after havinig it beaten in than tables are bad! bad! bad! will try it
wolf99 is offline   Reply With Quote
Old 05-17-2008, 11:49 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
i've been working on css a lot more lately. picked up a book called transcending css, i highly recommend it.

anyway, i decided to give this a shot tonight, here's what i came up with:
HTML Code:
<style>
/* clear unordered list style */
ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* define image set div css */
div.image-set {
  width: 250px;
  float: left;
}

/* define h2 style of image set */
div.image-set h2 {
  font-size: 1.1em;
  font-weight: bold;
}

/* define paragraph style of image set */
div.image-set p {
  font-size: .9em;
}

/* set your list element style */
div.image-set li {
	clear:both; /* adds clear because images inside these are floated left */
}

/* set your image-set images to float left with a margin */
div.image-set ul li img {
  float: left;
  margin: 5px;
}

/* set paragraph style of the text inside each list element */
div.image-set ul li p {
  padding-top: 5px;
}

/* clears floats so rest of html content can be displayed right */
.clearfix {
  clear:both;
  height: 0px;
}
</style>

<div class="image-set" id="set-A">
  <h2>Set Title Foo</h2>
  <p>Here is some info about this set.</p>

  <ul>
    <li><img src="/images/.../foo1.jpg" title="Foo1" alt="Foo1" width="50" height="50" /> <p>info about this image...</p></li>
    <li><img src="/images/.../foo2.jpg" title="Foo2" alt="Foo2" width="50" height="50" /> <p>info about this image...</p></li>
    <li><img src="/images/.../foo3.jpg" title="Foo3" alt="Foo3" width="50" height="50" /> <p>info about this image...</p></li>
    <li><img src="/images/.../foo4.jpg" title="Foo4" alt="Foo4" width="50" height="50" /> <p>info about this image...</p></li>
    <li><img src="/images/.../foo5.jpg" title="Foo5" alt="Foo5" width="50" height="50" /> <p>info about this image...</p></li>
  </ul>
</div>

<div class="image-set" id="set-B">
  <h2>Set Title Bar</h2>
  <p>Here is some info about this set.</p>

  <ul>
    <li><img src="/images/.../bar1.jpg" title="Bar1" alt="Bar1" width="50" height="50" /> <p>info about this image...</p></li>
    <li><img src="/images/.../bar2.jpg" title="Bar2" alt="Bar2" width="50" height="50" /> <p>info about this image...</p></li>
    <li><img src="/images/.../bar3.jpg" title="Bar3" alt="Bar3" width="50" height="50" /> <p>info about this image...</p></li>
    <li><img src="/images/.../bar4.jpg" title="Bar4" alt="Bar4" width="50" height="50" /> <p>info about this image...</p></li>
    <li><img src="/images/.../bar5.jpg" title="Bar5" alt="Bar5" width="50" height="50" /> <p>info about this image...</p></li>
  </ul>
</div>

<!-- clear your floats so they don't screw up html beyond this -->
<div class="clearfix"></div>
there should be a css element in the style area for most things you need to customize.
__________________
Mike
sde is offline   Reply With Quote
Old 05-18-2008, 11:21 AM   #5 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
DJMaze is on a distinguished road
Here's another (write-up in 1 minute)
HTML Code:
<style>
.image-set fieldset
{
    float:left;
    width:200px;
    height:200px;
}
.image-set fieldset img
{
    float:left;
}
.image-set div
{
     clear:both;
}
<style>

<div class="image-set" id="set-A">
    <fieldset>
        <legend>Image title</legend>
        <img src=""/>
        Image description
        <div></div>
    </fieldset>
    <div></div>
</div>
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS changing default text in BODY tag DavH27 HTML, XML, Javascript, AJAX 3 11-02-2006 08:57 AM
Include file shown correctly in FF not in IE Stoner HTML, XML, Javascript, AJAX 2 04-21-2006 07:56 AM
Text Searching freesoft_2000 Java 2 12-02-2004 07:38 AM
CSS Explorer trouble (of course) easilyi HTML, XML, Javascript, AJAX 6 11-11-2004 03:59 PM


All times are GMT -8. The time now is 01:37 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting