Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-11-2012, 10:31 PM   PM User | #1
wright67uk
New Coder

 
Join Date: Oct 2011
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
wright67uk is an unknown quantity at this point
Aligning form fields

Can anybody share some advice on how I can align my text with my form fields. This is what I have;


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<style type="text/css">
#midright1 {width:205px; height:130px; margin-bottom:10px; margin-left:10px; padding:5px; font-size:100%; clear:both; }
.emailtext {margin-top:16px;}
.firstname {margin-right:6px; float:right; }
.email {margin-right:6px; float:right; margin-bottom:4px; margin-top:4px;}
</style>

</head>

<body>

<div id="midright1">
<span style="font-weight: bold;">Free Report</span><hr />why do my form fields not align?<br /><br />
<span style="font-weight: bold;">Name </span> <input type="text" name="firstname" class="firstname"/><br/>
<span style="font-weight: bold" class="emailtext";>Email</span> <input type="text" name="email" class="email" /> <input type="submit" value="submit" /></div>
</body>
</html>
wright67uk is offline   Reply With Quote
Old 06-11-2012, 10:53 PM   PM User | #2
SeattleMicah
Regular Coder

 
Join Date: Dec 2011
Posts: 201
Thanks: 12
Thanked 26 Times in 26 Posts
SeattleMicah is an unknown quantity at this point
no css

Code:
<div id="midright1">
<span style="font-weight: bold;">Free Report</span> why do my form fields not align?<br>
<strong>Name:</strong><input type="text" name="firstname" class="firstname"/><br>
<strong>Email:</strong><input type="text" name="email" class="email"/> <input type="submit" value="submit" />
</div>
__________________
http://getfirebug.com/
SeattleMicah is offline   Reply With Quote
Old 06-12-2012, 05:26 AM   PM User | #3
wright67uk
New Coder

 
Join Date: Oct 2011
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
wright67uk is an unknown quantity at this point
Im not really sure what is meant by your answer.
I need to use CSS to posistion the field boxes to where I want them.

Now my task is to alight the text so that they are level with the boxes.
wright67uk is offline   Reply With Quote
Old 06-12-2012, 03:11 PM   PM User | #4
Will Bontrager
Regular Coder

 
Join Date: Jun 2012
Location: Near Chicago, USA
Posts: 123
Thanks: 7
Thanked 19 Times in 19 Posts
Will Bontrager is an unknown quantity at this point
Looks like .firstname needs float:left instead of float:right, clear:both removed from #midright1 and used instead in a div between table rows, .emailtext needs float:left, and both type="text" input fields float:right. That is, if I understand what you are trying to accomplish.

Something like this might work.

Code:
<!-- inline CSS can be transferred to style sheet -->
<div style="width:205px;">
<div style="float:left; padding-top:3px;">Name:</div>
<div style="float:right;"><input type="text" style="width:150px;"></div>
<div style="clear:both; height:4px;"></div>
<div style="float:left; padding-top:3px;">Email:</div>
<div style="float:right;"><input type="text" style="width:150px;"></div>
<div style="clear:both;"></div>
<input type="submit" style="margin-top:4px;">
</div>

Will
__________________
Numerology API for apps - Facebook, iPad, mobile phones. No charge to use API. [info]
Will Bontrager is offline   Reply With Quote
Old 06-12-2012, 03:47 PM   PM User | #5
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Have a look at http://www.alistapart.com/articles/p...ccessibleforms

That will help you to setup an accessible form too.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Reply

Bookmarks

Tags
css, form fields, forms, html

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:24 AM.


Advertisement
Log in to turn off these ads.