Forum Moderators: not2easy

Message Too Old, No Replies

A Form, CSS, an image, and a spacing issue

Putting image next to input text adds space

         

nickels

4:34 pm on Jun 19, 2007 (gmt 0)

10+ Year Member



I am pulling my hair out trying to figure this issue out: <url snip>

Check out that page. See how on the top two div's there is an input text box with fake info on it, both are aligned to the top of the div. Then on the third div I simply added an image next to it, and suddenly space is added above the input text box.

The forth div has text next to the input text as a test to see what happens. No space is added. The fifth div has a button instead of an image, and the result here is the same as an image, there is space created for some reason.

What is causing this? Any help is appreciated!

Code added:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css" media="all">
</style>
</head>
<body>
<div style="border:1px solid #000066">
<input type="text" size="24" value="testing 1 2 3" />
</div>
<br />
<div style="border:1px solid #000066; padding:0; margin:0; height:50px; top: 65%;"><form action="#*$!.html" method="post"><input type="text" size="24" value="testing 1 2 3" /></form></div>
<br />
<div style="border:1px solid #000066; padding:0; margin:0; height:50px;">
<input type="text" size="24" value="testing 1 2 3" style="padding:0; margin:0;" /> <a href="#" style="padding:0; margin:0;"><img style="padding:0; margin:0;" src="images/btn-search.gif" width="28" height="20" border="0" alt="Search Button" /></a></div>
<br />
<div style="border:1px solid #000066; padding:0; margin:0; height:50px;">
<input type="text" size="24" value="testing 1 2 3" style="padding:0; margin:0;" />text</div>
<br />
<div style="border:1px solid #000066; padding:0; margin:0; height:50px;">
<input type="text" size="24" value="testing 1 2 3" style="padding:0; margin:0;" />
&nbsp;<input type="image" src="images/btn-search.gif" alt="Submit details" />
</div>
</body>
</html>

Note: image and input type image are both 28px x 20px

edit reason: sample link removed and code added per guidelines for forum [webmasterworld.com]

[edited by: SuzyUK at 4:50 pm (utc) on June 19, 2007]

OPPS! - Sorry I just notice that url rule and I came to fix my post, but you already did. Sorry mod.

Milamber

5:07 pm on Jun 19, 2007 (gmt 0)

10+ Year Member



just add vertical-align:top; to the styling of your input boxes.

nickels

5:55 pm on Jun 19, 2007 (gmt 0)

10+ Year Member



That worked.
Don't code with no sleep the night before.
(I swear I tried to vertical-align everything in that div without success)

Thanks!