Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / CSS / February 2007



Tip: Looking for answers? Try searching our database.

align text field and button 2

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
finecur - 21 Feb 2007 23:26 GMT
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
Ben C - 22 Feb 2007 11:15 GMT
> Hi,
>
[quoted text clipped - 17 lines]
>
> 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>
John Hosking - 22 Feb 2007 11:43 GMT
>>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.

Signature

John

Ben C - 22 Feb 2007 12:13 GMT
>>>I can not figure out how to do it.
>
[quoted text clipped - 5 lines]
>
> 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?
Jukka K. Korpela - 22 Feb 2007 13:05 GMT
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?

Signature

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

Ben C - 22 Feb 2007 13:35 GMT
> 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:

finecur> The width of the second row (and thus the width of the table)
finecur> is changing depending on its content. I want, however, in the
finecur> first row, "Name" is always left aligned. The button is always
finecur> right aligned. And the text filed fill all the space between
finecur> them.

> 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.
dorayme - 22 Feb 2007 22:09 GMT
> Scripsit Ben C:
>
[quoted text clipped - 3 lines]
> 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.

Signature

dorayme

dorayme - 22 Feb 2007 22:09 GMT
> 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... :)

Signature

dorayme

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.