Divs in a row

This is a discussion on "Divs in a row" within the Web Page Design section. This forum, and the thread "Divs in a row are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 17th, 2006, 14:36
Junior Member
Join Date: Aug 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Divs in a row

I'm trying to scrap the awful table layout on the site i'm working on, to make it more fluid.
Where there were, say, 4 td elements in a row, I wanted it to resize to the screen so you could have more elements, or less. I've put a bunch of divs in a row and let them wrap according to space.
You can see where I'm up to here: http://www.aocd00.dsl.pipex.com/files/floor.php
I've got so far with this but am having a few problems:
1. how do i center the layout, such that however many divs fit on a line, with equal space on each side of the page?
2. If the content of one of the divs pushes its height beyond the height of its neighbours, then any subsequent wrapping is this extended div, rather than the beginning of the line (kind of hard to explain this - see the link). Can I force it to wrap to the next line?
3. I've stuck with table layout within each div as i couldn't get the text to align vertically otherwise. How do i do this without tables?
Here's code:
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<div style="float:left">
  <table width="250">
    <tr>
      <td>
        <img src="images/emailchair.gif" height="100" width="100">
      </td>
      <td>
      Some flkfqwlhfwe fweilohcfeoi hcfweloih cwekih coih
      </td>
    </tr>
  </table>
</div>
<div style="float:left; height:150px;">
  <table width="250" >
    <tr>
      <td>
        <img src="images/emailchair.gif" height="100" width="100">
      </td>
      <td>
      Some flkfqwlhfwe fweilohcfeoi hcfweloih cwekih coih<br>jhgfiuwehf<br>oihfoewhiofw<br>hhjuer<br>ihfoiweh<br>kijfeoijhoi<br>uuihuefwi
      </td>
    </tr>
  </table>
</div>
<div style="float:left">
  <table width="250">
    <tr>
      <td>
        <img src="images/emailchair.gif" height="100" width="100">
      </td>
      <td>
      Some flkfqwlhfwe fweilohcfeoi hcfweloih cwekih coih
      </td>
    </tr>
  </table>
</div>
<div style="float:left">
  <table width="250">
    <tr>
      <td>
        <img src="images/emailchair.gif" height="100" width="100">
      </td>
      <td>
      Some flkfqwlhfwe fweilohcfeoi hcfweloih cwekih coih
      </td>
    </tr>
  </table>
</div>
</body>
</html>
Reply With Quote

  #2 (permalink)  
Old Feb 17th, 2006, 14:54
herkalees's Avatar
Highly Reputable Member
Join Date: Jul 2005
Location: Massachusetts, USA
Age: 87
Posts: 576
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to herkalees Send a message via MSN to herkalees Send a message via Yahoo to herkalees
Re: Divs in a row

I don't know the answer (or even understand the question) to number two, but numbers one and three are answered in the results of this modified code:
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Yay</title>
<style type="text/css" media="all">
div#wrap {
	margin: 0 auto; /*This centers the 4 divs*/
	width: 1000px; /*This number is necessary, it is the total of your 4 divs. Removing it ends the centering abilitly.*/
}
div.block {
	float: left;
	width: 250px;
	background-color: #cff; /*This just shows the area taken up by each div, delete when necessary*/
}
div.block img {
	background-color: #ffc; /*This just shows the area taken up by an image, delete when necessary*/
	display: block; /*This puts the image on it's own line, remove if desired*/
}
</style>
</head>
<body>
<div id="wrap">
  <div class="block"><img src="" height="100" width="100" alt="image">Some flkfqwlhfwe fweilohcfeoi
    hcfweloih cwekih coih</div>
  <div class="block"><img src="" height="100" width="100" alt="image">Some flkfqwlhfwe fweilohcfeoi
    hcfweloih cwekih coih<br>
    jhgfiuwehf<br>
    oihfoewhiofw<br>
    hhjuer<br>
    ihfoiweh<br>
    kijfeoijhoi<br>
    uuihuefwi</div>
  <div class="block"><img src="" height="100" width="100" alt="image">Some flkfqwlhfwe fweilohcfeoi
    hcfweloih cwekih coih</div>
  <div class="block"><img src="" height="100" width="100" alt="image">Some flkfqwlhfwe fweilohcfeoi
    hcfweloih cwekih coih</div>
</div>
</body>
</html>
Reply With Quote
  #3 (permalink)  
Old Feb 17th, 2006, 15:02
Junior Member
Join Date: Aug 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Divs in a row

OK but now it won't wrap to the size of the screen.
Reply With Quote
  #4 (permalink)  
Old Feb 17th, 2006, 15:05
herkalees's Avatar
Highly Reputable Member
Join Date: Jul 2005
Location: Massachusetts, USA
Age: 87
Posts: 576
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to herkalees Send a message via MSN to herkalees Send a message via Yahoo to herkalees
Re: Divs in a row

yeah, that's because of the defined 1000px width (which is necessary to make it center itself).

I'm not sure how to make both possible, but someone else might pipe up and tell you.

In the meantime, if you remove the line of CSS that states the 1000px width, you'll get the wrapping.
Reply With Quote
  #5 (permalink)  
Old Feb 17th, 2006, 17:10
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Divs in a row

Center the text in the body style
Text left in the wrapper div and set Width=95% or whatever.
Reply With Quote
  #6 (permalink)  
Old Feb 17th, 2006, 18:40
herkalees's Avatar
Highly Reputable Member
Join Date: Jul 2005
Location: Massachusetts, USA
Age: 87
Posts: 576
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to herkalees Send a message via MSN to herkalees Send a message via Yahoo to herkalees
Re: Divs in a row

There ya go, I'm not thinking clearly today...
Reply With Quote
Reply

Tags
divs, row

Thread Tools

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
Having two divs which do not affect each other? LGS Web Page Design 11 Oct 28th, 2007 23:41
Style with DIVS cyberseed Web Page Design 5 Oct 31st, 2006 14:37
Divs in a row hessodreamy Web Page Design 1 Nov 15th, 2005 15:58


All times are GMT. The time now is 03:25.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43