Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Think I'm going to cry - CSS fluid tableless layout

Featured Replies

It looks like a very simple layout, to me at least, but after struggling over it for several hours I seriously need help.

 

Here's what I'm trying to do:

underconstructionn.jpg

 

Here is what it currently looks like - www.thetvrsite.com

I have had a look at your code.

 

For a start you are missing the <div> tag.

 

Also the table row - which you have called bottom-row - has not cells.

 

I have only had a quick look at the CSS but you dont really need to use as much CSS code as you have.

 

Your HTML should be something like:

 

<table class="screen">
<tr class="top-row">

	<td id="t-left"><img src="/temp-images/logo.jpg" alt="The TVR Site Logo"/></td>
	<td id="t-middle"> </td>
	<td id="t-right"> </td>
</tr>

<tr class="middle-row">
	<td id="m-left"> </td>
	<td id="m-middle"><img src="/temp-images/cerbera.jpg" alt="The TVR Site Logo"/></td>
</tr>

<tr class="bottom-row">
               <td id="b-left"> </td>
	<td id="b-middle"><img src="/temp-images/cerbera.jpg" alt="The TVR Site Logo"/></td>
<td id="b-bottom"> </td>
</tr>

  • Author

Sorry, you've caught it whilst I'm in the middle of going from tableless, to tabled. Managed to get hold of a web-designer friend of mine who said the original design would be a nightmare in pure CSS.

 

One question I now have though, is no matter what I do I can't seem to get border-collapse: collapse to work? :S

It would not be a nightmare. You could pull it off quite easy by using those lines as background or just simple div tags.

  • Author

OK, I best explain exactly what I want, as my friend thought it would be easy at first.

 

Everything is kind of relative around that middle image. The 'cell' that the image is in should be exactly the same size as that image, therefore if the image is in a table cell or a div, its size must be fixed.

 

The top row, and left column must be fluid, at about 45-60%. The bottom row and right column must be fluid, but extend to the edge of the screen.

 

The borders must edge the middle image, and extend to the edges of the screen. It must all be fluid, so the page appears the same regardless of resolution.

as above is pretty easy to do in pure css e.g.

 

 left1 {
  width:40%;
  border-right: 1px solid #ffffff;
  border-bottom:1px solid #ffffff;
}
#left2 {
  width:40%;
  border-right: 1px solid #ffffff;
  border-bottom:1px solid #ffffff;
}
#left 3 {
 width:40%;
}

#center1 { 
  width:30%;
  border-right: 1px solid #ffffff;
  border-bottom:1px solid #ffffff;
}

#center2 {

  width:30%;
  border-right: 1px solid #ffffff;
  border-bottom:1px solid #ffffff;
}
#center3 {
  width:30%;
  border-right: 1px solid #ffffff;
}
#right1 {
  width:30%;
  border-bottom:1px solid #ffffff;
}
#right2 {
  width:30%;
  border-bottom:1px solid #ffffff;
}
#right 3
width:30%;
}

 

all you would need to do is add height to each one if needed and set the overall background in a wrapper div

  • Author

But surely, if say left is at 40%, then centre is always set at 250px, then setting right at 30% may not extend to the end of the screen, or may extend past it?

But surely, if say left is at 40%, then centre is always set at 250px, then setting right at 30% may not extend to the end of the screen, or may extend past it?

 

i wouldn't use 2 rows set at fluid and 1 fixed, i use all 3 as fluid ... you would set the image for the divs as the background,

 

if all the percentages set too 100% total then it shouldn't stretch over the edge.... and would keep the same layout when viewing in different resolutions

 

but you could change to using fixed width such as 300px but on smaller screens its not gonna look good e.g. 10" netbooks for example

  • Author
i wouldn't use 2 rows set at fluid and 1 fixed, i use all 3 as fluid ... you would set the image for the divs as the background,

But with the centre column set as fluid the borders that should travel along the side edges of the image would stay there.

You're always going to have problems when trying to use fluid widths/heights and images.

Instead of having 9 <divs>, why not try having just 2 with the image inside one of them?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 <link rel="stylesheet" href="style.css" type="text/css" />
 </head>
 <body>
 <div class="vert">
 <img src="sample.jpg" />
 </div>
 <div class="hori"></div>
 </body>
 </html>

I would then use absolute positioning for both divs (in this example one is 45% from the left and the other is 40% from the top. Both have a fixed height/width to accomodate the image. Then position the image absolutely inside its containing div (40% from the top in this case).

* {
margin:0;
padding:0;
}
body {
background:#3b3738;
height:100%;
}
.vert{
position:absolute;
left:45%;
border-right:2px solid #9f9d9e;
border-left:2px solid #9f9d9e;
width:250px;
height:100%;
}
.hori {
position:absolute;
top:40%;
height:150px;
width:100%;
border-top:2px solid #9f9d9e;
border-bottom:2px solid #9f9d9e;
}
img {
position:absolute;
top:40%;
left:0;
width:250px;
height:152px;
padding:0;
border:0;
margin:0;
}

The bottom 'row' and right 'column' will decrease with the window size and on smaller res will be very small indeed.

The downside to this is that although this is fluid, all other elements on the page will need to positioned absolutely too. Not so much a problem if not text heavy but not very practical tbh. Is this just a holding page or will the rest of the site keep this format?

 

Anyway, here's an example. (not tested on anything than FF3 and Opera) but should be fine

 

EDIT: Forgot to post the css :rolleyes:

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.