By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,630 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,630 IT Pros & Developers. It's quick & easy.

align text field and button 2

P: n/a
Hi,

Here is my html:
<table>
<tr>
<td colspan=2>Name <input type=text...><input type=button...></td>
</tr>
<tr>
<td>....</td>
<td>....</td>
</tr>
</table>
The width of the second row (and thus the width of the table) is
changing depending on its content. I want, however, in the first row,
"Name" is always left aligned. The button is always right aligned.
And
the text filed fill all the space between them.
I can not figure out how to do it. Can anyone help?
Thanks,
ff

Feb 21 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On 2007-02-21, finecur <fi*****@yahoo.comwrote:
Hi,

Here is my html:
<table>
<tr>
<td colspan=2>Name <input type=text...><input type=button...></td>
</tr>
<tr>
<td>....</td>
<td>....</td>
</tr>
</table>
The width of the second row (and thus the width of the table) is
changing depending on its content. I want, however, in the first row,
"Name" is always left aligned. The button is always right aligned.
And
the text filed fill all the space between them.
I can not figure out how to do it. Can anyone help?
The problem is rather difficult. The table's width depends on the
contents of the second row, but you want the widths of things in the
first row to be a function of that computed width.

I have a solution that works in Opera, FF and Konqueror. It's dodgy
because it involves setting percentage widths of auto-width containers,
which the browser is entitled to ignore.

By using a nested table, we dissociate the three columns in the first
row from the three in the second row.

Setting "Name" and "click" to 1px each is intended to make the browser
shrink them to their content minwidth, leaving everything else in the
middle for the text input.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<title>Test Page</title>
<style type="text/css">
td { border: 1px solid green; }
</style>
</head>
<body>
<table>
<tr>
<td colspan="2">
<table style="width: 100%">
<tr>
<td style="width: 1px">Name</td>
<td>
<input type="text" style="width:100%">
</td>
<td style="width: 1px">
<input type="button" value="click">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
content content content content
</td>
<td>
content content
</td>
</tr>
</table>
</body>
</html>
Feb 22 '07 #2

P: n/a
Ben C wrote:
On 2007-02-21, finecur <fi*****@yahoo.comwrote:
>>I can not figure out how to do it.
or post in newsgroups
I have a solution that works in Opera, FF and Konqueror.
[rest of generously provided solution snipped]
finecur should consider itself very, very lucky.

--
John
Feb 22 '07 #3

P: n/a
On 2007-02-22, John Hosking <Jo**@DELETE.Hosking.name.INVALIDwrote:
Ben C wrote:
>On 2007-02-21, finecur <fi*****@yahoo.comwrote:
>>>I can not figure out how to do it.

or post in newsgroups
>I have a solution that works in Opera, FF and Konqueror.

[rest of generously provided solution snipped]
finecur should consider itself very, very lucky.
Actually I have no problem with finecur, since the problem was not
difficult to understand as posted.

The "post a url to a test page that validates" rule is a good one in
general, but if it's clear what the problem is in a few lines of markup
then why not?
Feb 22 '07 #4

P: n/a
Scripsit Ben C:
Actually I have no problem with finecur, since the problem was not
difficult to understand as posted.
You didn't get upset with pointless repetitive postings that indicated
little understanding of the answers so far? (Just a rhetoric question.)
The "post a url to a test page that validates" rule is a good one in
general, but if it's clear what the problem is in a few lines of
markup then why not?
Because there is too little information to know what the problem really was.
We have no explanation for the apparently pointless colspan, for example.

Your proposed a solution that you admitted to be dodgy and declared as
working some browsers, which exclude IE, i.e. most browsing situations. What
possible problem would justify such a solution?

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Feb 22 '07 #5

P: n/a
On 2007-02-22, Jukka K. Korpela <jk******@cs.tut.fiwrote:
Scripsit Ben C:
[...]
>The "post a url to a test page that validates" rule is a good one in
general, but if it's clear what the problem is in a few lines of
markup then why not?

Because there is too little information to know what the problem really was.
We have no explanation for the apparently pointless colspan, for example.
True, the colspan is a puzzle. But the English explanation was clear
enough to me:

finecurThe width of the second row (and thus the width of the table)
finecuris changing depending on its content. I want, however, in the
finecurfirst row, "Name" is always left aligned. The button is always
finecurright aligned. And the text filed fill all the space between
finecurthem.
Your proposed a solution that you admitted to be dodgy and declared as
working some browsers, which exclude IE, i.e. most browsing situations. What
possible problem would justify such a solution?
An interesting problem, which I tried to characterize and presented a
dodgy solution to in the hope that someone would be able to improve on
it.
Feb 22 '07 #6

P: n/a
In article <xy***************@reader1.news.saunalahti.fi>,
"Jukka K. Korpela" <jk******@cs.tut.fiwrote:
Scripsit Ben C:
Actually I have no problem with finecur, since the problem was not
difficult to understand as posted.

You didn't get upset with pointless repetitive postings that indicated
little understanding of the answers so far? (Just a rhetoric question.)
It is quite noticeable and admirable in a
'beyond-the-call-of-duty' sort of a way, how tolerant Ben C is
about these things! Perhaps he had an unusually happy childhood.

--
dorayme
Feb 22 '07 #7

P: n/a
In article <sl*********************@bowser.marioworld>,
Ben C <sp******@spam.eggswrote:
>
The "post a url to a test page that validates" rule is a good one in
general, but if it's clear what the problem is in a few lines of markup
then why not?
The key phase here being "if", of course... :)

--
dorayme
Feb 22 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.