473,499 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Text input field plus image should have total width of N em

I would like to put a text input field (in the sense of <input
type="text">) and an image next to each other, where I know the size
in pixels of the image, and I know the total width in em. I haven't
found a way to do this.

I tried

<span style="width:20em">
<input type="text">
<img width="25px" src="...">
</span>

And I also tried

<table>
<td width="*"><input type="text"></td>
<td width="25px"><img src="..." width="25px"></td>
</table>

And I also tried a number of other things, but the above give you the
idea which direction I was looking.

In all cases, the <input type="text"> doesn't resize to match the
total width. Is there a way to achieve this?

(If the total width is given in px, then I guess I can just compute
the width of the <input type="text"> and Bob's my uncle. But what if
the total width is given in em, not px?)

tia,
Kai
Jul 20 '05 #1
2 4973
Ka*************@gmx.net (Kai Grossjohann) wrote:
I would like to put a text input field (in the sense of <input
type="text">) and an image next to each other, where I know the size
in pixels of the image, and I know the total width in em.
Since this is a presentational problem, it might belong to
c.i.w.a.stylesheets rather than c.i.w.a.html. I'm not setting
followups, though, since the nature of the problem is rather unclear.

You need to describe the problem in more detail. What do you mean by
knowing the total width in em? What is the context? (And is it really
useful to put the input field and the image next to each other? Why?)

If you just use <input ...><img ...>, then the elements will appear
next to each other. But presumably you want something else, too.
I tried

<span style="width:20em">
<input type="text">
<img width="25px" src="...">
</span>
Please explain what you are trying to accomplish, instead of just
giving some sketch markup, which isn't even valid. And what effect do
you expect the width property for span to have? By the specifications,
it should have no effect.
And I also tried

<table>
<td width="*"><input type="text"></td>
<td width="25px"><img src="..." width="25px"></td>
</table>
Again, the markup isn't even valid. It's actually grossly malformed.
And I also tried a number of other things, but the above give you the
idea which direction I was looking.
No, incorrect markup does not tell what you expect to achieve.
In all cases, the <input type="text"> doesn't resize to match the
total width. Is there a way to achieve this?


Oh. So _that_ is the real problem? But you still need to explain in
more detail. Specifically, which "total width"? So you mean that you
would like to set the sum of the widths of an <input> element and an
<img> element to 20em so that the <img> element is of fixed width in
pixels and the <input> element occupies the rest? Why didn't you say
this in the first place? And your snippets indicate _no_ attempt to set
the width of the <input> element.

Well, there's really no way to subtract pixel values from em values.
Why would you try that? Isn't it simpler to set the width of the
<input> element to the desired value, say 20em or 18em, and leave it at
that? Actually, setting the width using the size="..." attribute in
HTML is more constructive than using em units, since the size attribute
uses a natural unit, the width of an average character (though some
browsers are known to get this wrong in the sense of using a larger
value).

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #2
"Jukka K. Korpela" <jk******@cs.tut.fi> writes:
Oh. So _that_ is the real problem? But you still need to explain in
more detail. Specifically, which "total width"? So you mean that you
would like to set the sum of the widths of an <input> element and an
<img> element to 20em so that the <img> element is of fixed width in
pixels and the <input> element occupies the rest?
Exactly this is what I tried to accomplish. As the subject says:

"Text input field plus image should have total width of N em"

The only part that's missing from the subject is the fact that the
image has a fixed width in pixels. I think this becomes clear from
the examples, all of which show that the image is 25px wide.
Why didn't you say this in the first place?


I tried to...

But thank you very much for understanding me anyway, even though I
described my wishes so badly.

Do you have a suggestion?

Kai
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
148518
by: Steve Speirs | last post by:
Hi I'm trying to show/hide a simple piece of text and a text field on a form based on what choice is made from a drop down box. <select name="dropdown" size="1"> <option selected...
3
16499
by: Bjoern Wolfgardt | last post by:
Hi, I am a little bit confused. Maybe someone can explain what I am doing wrong. I have a table with 2 cells in it. In the first cell I have an image. The image is left aligned and centered....
2
4526
by: Lovely Angel For You | last post by:
Dear Friends Hope you all are doing great. I am using a form to add text data to the database. With this form I am also using a file field to upload a image file. To use the first thing that...
3
3964
by: acecraig100 | last post by:
I am fairly new to Javascript. I have a form that users fill out to enter an animal to exhibit at a fair. Because we have no way of knowing, how many animals a user may enter, I created a table...
2
3724
elamberdor
by: elamberdor | last post by:
Hi All! Well, i'm modifying a dynamic map, with lat and long datapoints, my problem is it loads in text perfectly onto exact points I specify on the map, ..well now I want to load in...
3
1723
omerbutt
by: omerbutt | last post by:
hi there i have a tbl in db which has following fields table name:stock id_no(primary key...autono) part_name(text) price(currency) now i have an asp and htmlbased form in which i have made a...
1
4182
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
11
12282
by: Mike Harrison | last post by:
Hi, I have some simple HTML like this: <div id="container" style="width:100%;"> <input type="text" <input type="button" style="float:right;" value="Click here..."> </div> I want the button...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7386
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.