views:

99

answers:

6

The 'required' text is showing up to the left of the input box. Similar problem in Opera except is displays on the next line (creates a line break). Looks as expected in FF3.1 and chrome. Any suggestions? Eventually I would like to use the display:none attribute on the 'required' span and show this span as necessary with javascript.

<html>
<head>
<title></title>

<style type="text/css">
<!--
input.missing { background-color: #FFFF77; }

div.row {
  clear: both;
  padding-top: 5px;
   }

div.row span.label {
  float: left;
  width: 100px;
  text-align: right;
  }

div.row span.formw {
 // float: right;
  width: 235px;
  text-align: left;
  padding-right: 0px;
  padding-left: 45px;

  } 

div.spacer {
  clear: both;
 }

.container{
  width: 425px; 
  background-color: #ccc;
  border: 1px dotted #333;
  padding: 5px 5px 5px 5px; 
 margin: 0px auto;
 }

 .error{
    color: #ff0000;
  }

 .required{
  color: #ff0000;
  float: right;
 // display:none;
//  display:inline;
  }
-->
</style>
</head>
<body>
<div id="contact_form">
<form action="/jr/index.php" method="POST" id="contact">

<div id="top_message" style="width: 360px; margin: 10px auto;">
Enter Your Information Below</div>


<div class="container">

    <div class="row">
      <span class="label">Name:</span>
      <span class="formw"><input size="30"  maxlength="30" name="name" id="name" value=""></span>
    </div>

  <div class="row">
      <span class="label">Email:</span>
      <span class="formw"><input size="30"  maxlength="30" name="email" id="email" value=""></span>
      <span id="email_error" class="required">(required)</span>
    </div>

    <div class="row">
      <span class="label">Shoe size:</span><span
class="formw"><input type="text" size="25" /></span>
    </div>
    <div class="row">
     <span class="formw">
      <input type="image" value="submit" name="submit" class="button" src="submit.png" alt="Submit" /></span>
    </div>
  <div class="spacer">
  &nbsp;
  </div>

</div>

<div id="message_ajax" style="width: 360px; margin: 10px auto;"></div>    

</form>
</div>
</body>
</html>

IE really makes me hate web dev sometimes.

+3  A: 

You probably should start by adding the proper DocType tag at the top of your file.

EDIT: After looking at your code, it appears you are not using your floats properly. First off - // does NOT comment out lines in a CSS file. You need to wrap it in /* and */ to comment it out. So your SPAN.formw style is floating to the right, which is before your SPAN.required, which also floats right. Since you're using SPAN tags, you really don't need to float anything here. If you remove all of those it should just fall into place for you.

Shawn Steward
Thanks, that surprisingly fixed it! I used transitional btw.
jriggs
Not so surprisingly ;) Without the doctype, IE will run in Quirks mode which is just a mess.
Shawn Steward
Good spot.........
AJM
@Shawn- removed the floats. Before posting I ran it through the validator and it didn't complain about them (did complain about doctype though..d'oh). But you are correct I don't need them.
jriggs
Yeah you can use them and they're valid, but they are unnecessary the way you're displaying the form fields.
Shawn Steward
+3  A: 

Which doctype are you using ? A strict one may prevent that kind of problem... Also, I usually start my CSS design with a reset file to get rid of all those kind of annoyances : http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/

Wookai
+1 for mention of the Meyer CSS Reset file, gotta love it :)
Shawn Steward
A: 

Put a float:left on the formW class

AJM
A: 

Float all the boxes in the row to the left, instead of mixing floating and inline elements:

div.row span.label {
  float: left;
  width: 100px;
  text-align: right;
  }

div.row span.formw {
  float: left;
  width: 235px;
  padding-left: 45px;
  }

.required{
  float: left;
  color: #ff0000;
  // display:none;
  }
Guffa
+3  A: 

Using double slash "//" is not valid CSS commenting. So this float right rule:

div.row span.formw { // float: right;

Is being applied.

Use:

/* comment */

When commenting CSS.

graphicdivine
A: 

jriggs, since IE8 is still not completely stable, for some projects you can have IE8 revert to IE7 rendering rules. One of the benefits is that this doesn't give the user the compatibility view button on the right of the location bar.

For more info and specifics see http://blogs.msdn.com/ie/archive/2008/06/10/introducing-ie-emulateie7.aspx

Archit Baweja