Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

div tag

Status
Not open for further replies.

neonep

Programmer
Jun 26, 2003
34
Hi all,

I need to position 2 text boxes on an image. I used the div tag to accomplish this but seems like when I make the font of the browser bigger or smaller, the text boxes move around and don't show up on the place I want them to. Can you show me an example of an HTML tag that would make the boxes relative to the image and resize and move according to the image? Thanks.

i have included the code below. Just open it with a browser and press "Ctrl-" to decrease the font and "Ctrl+" to increase it and you will see the boxes moving around.

<html>
<head>

<script language="JavaScript" type="text/JavaScript">
<!--
function doT ()
{

}

//-->
</script>
</head>

<body>

<br><br><br><br>

<form name="myform">

<input type="hidden" name="at"></input>

<div id="Layer1" style="position:absolute; left:132px; top:328px; width:140px; height:14px; z-index:1">
<input name="rn" type="text" size="20" maxlength="10">
</div>
<div id="Layer2" style="position:absolute; left:315px; top:328px; width:140px; height:14px; z-index:2">
<input name="an" type="text" size="20" maxlength="10">
</div>


<table width="750px" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="20%">&nbsp;</td>
<td width="30%"><div align="center">
<input type="radio" name="radiobutton" onclick="document.myform.at.value='c'">
Fixed</div></td>
<td width="30%"><div align="center">
<input type="radio" name="radiobutton" onclick="document.myform.at.value='s'">
Not fixed</div></td>
<td width="20%">&nbsp;</td>
</tr>
<tr>
<td colspan="4"><div align="center"><img src="sample.gif" width="578" height="267"></div></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2"><div align="center">
<input type="button" name="submit" value="submit" onclick="javascript:doT()">
</div></td>
<td>&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>
 

This works for me:

Code:
<div style="position:relative;">
	<div id="Layer1" style="position:absolute; left:120px; top:220px; width:140px; height:14px; z-index:1">
		<input name="rn" type="text" size="20" maxlength="10" />
	</div>
	<div id="Layer2" style="position:absolute; left:280px; top:220px; width:140px; height:14px; z-index:2">
		<input name="an" type="text" size="20" maxlength="10" />
	</div>
	<div align="center">
		<img src="sample.gif" width="578" height="267" />
	</div>
</div>

Incidentally, changing the text size using the keypresses you mention does not work in IE.

Hope this helps,
Dan

 
Thanks for your reply but is there a way that the text boxes don't change in size? I mean they need to be fixed on the image. If you decrease or increase the font size, the image stays fixed but the text boxes become small and misplaced.

and yeah Ctrl+ and Ctrl- work with epiphany and mozilla on linux.
 

Define a style on the input boxes using EMs:

Code:
<input type="text" style="font-size:1em;" />

Hope this helps,
Dan

 
I tried that but the text boxes still increase and decrease in size irrelative to the image. This is the first time I am using css and dhtml. If it's not much of a problem, could you please show me an example with the code I provided above?
 

Sorry - I misunderstood what you were asking. AFAIK, there is NO way you can stop FF / Moz / NN from reducing the size of the input box UNLESS you specify its width and height explicitly:

Code:
<input name="rn" type="text" size="20" maxlength="10" style="width:100px; height:14px;" />

Hope this helps,
Dan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top