Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Centering middle cell, code included.

Reply
Thread Tools

Centering middle cell, code included.

 
 
luke
Guest
Posts: n/a
 
      10-20-2004
I need to have two different backgrounds, one on the left and one on the
right of the screen, with the main content centered in the browser. This is
the code I have come up with

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="49%" background="left.gif"><img src="shim.gif" alt=""
height="1" width="1"></td>
<td width="2%" valign="top"> ALL CONTENT </td>
<td width="49%" background="right.gif"><img src="shim.gif" alt=""
height="1" width="1"></td>
</tr>
</table>

This seems to work perfectly, however I'm slighlty unsure as the numbers
don't add up. Say my Content in the middle cell is a 750 pixel wide nested
table, this would obviously mean that the percentage are not as described.
Is there a chance that certain browsers will choke on this code? and maybe
not display the middle cell in the middle of the page?


 
Reply With Quote
 
 
 
 
Kris
Guest
Posts: n/a
 
      10-20-2004
In article <cl695d$qce$>,
"luke" <> wrote:

> I need to have two different backgrounds, one on the left and one on the
> right of the screen, with the main content centered in the browser. This is
> the code I have come up with
>
> <table border="0" cellpadding="0" cellspacing="0" width="100%">
> <tr>
> <td width="49%" background="left.gif"><img src="shim.gif" alt=""
> height="1" width="1"></td>
> <td width="2%" valign="top"> ALL CONTENT </td>
> <td width="49%" background="right.gif"><img src="shim.gif" alt=""
> height="1" width="1"></td>
> </tr>
> </table>
>
> This seems to work perfectly, however I'm slighlty unsure as the numbers
> don't add up. Say my Content in the middle cell is a 750 pixel wide nested
> table, this would obviously mean that the percentage are not as described.
> Is there a chance that certain browsers will choke on this code? and maybe
> not display the middle cell in the middle of the page?


Wait, you mean, all that when this will do?

CSS:
body {
color: #000;
background: url("750pxwidegreenblock.png") #0000cc repeat-y;
text-align: center;
}
#content {
width: 750px;
margin: 0 auto;
text-align: left;
color: #000;
background: green;
}

HTML:
<body>
<div id="content">
Whatever content you have.
</div>
</body>

--
Kris
<> (nl)
 
Reply With Quote
 
 
 
 
luke
Guest
Posts: n/a
 
      10-20-2004
"Kris" <> wrote in message
news:kristiaan-...

>
> Wait, you mean, all that when this will do?


Wait, I think you misread my post!


 
Reply With Quote
 
Kris
Guest
Posts: n/a
 
      10-20-2004
In article <cl6aqo$vc6$>,
"luke" <> wrote:

> > Wait, you mean, all that when this will do?

>
> Wait, I think you misread my post!


Maybe. So now what?

--
Kris
<> (nl)
 
Reply With Quote
 
jmm-list-gn
Guest
Posts: n/a
 
      10-20-2004
luke wrote:
> <td width="49%" background="left.gif"><img src="shim.gif" alt=""
> <td width="2%" valign="top"> ALL CONTENT </td>
> <td width="49%" background="right.gif"><img src="shim.gif" alt=""
> This seems to work perfectly, however I'm slighlty unsure as the numbers
> don't add up.
>

My math says that 49 + 2 + 49 = 100. Seems to add up.

> Say my Content in the middle cell is a 750 pixel wide nested
> table, this would obviously mean that the percentage are not as described.
>

Why do you care? You already ignore the percentages to get an
expandable middle section. If the total image widths exceed the viewable
area, the table expands beyond the view.
You'd have to view the result with different browsers to verify how
they handle it.

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
 
Reply With Quote
 
Robert Frost-Bridges
Guest
Posts: n/a
 
      10-21-2004
luke wrote:

> I need to have two different backgrounds, one on the left and one on
> the right of the screen, with the main content centered in the
> browser. This is the code I have come up with


Join the two backgrounds together using a graphics program then use
Kris' example with this single background.

--
frostie
http://brightonfixedodds.net
 
Reply With Quote
 
 
 
Reply

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shoving dynamic code in the middle of a page. UJ ASP .Net 4 05-25-2005 04:13 PM
Centering button in a datagrid column tshad ASP .Net 17 12-03-2004 04:48 PM
choices regarding where to place code - in the database or middle tier Joe Java 71 06-24-2004 08:58 PM
Centering ValidationSummary in a cell of a table NWx ASP .Net 1 02-11-2004 06:22 PM
Centering controls on a Web Form Joe Bonavita ASP .Net 1 12-23-2003 05:20 PM



Advertisments
 



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 44 45 46 47 48 49 50 51 52 53 54 55 56 57