0

I'm a newbie to web development, so this might sound dumb.

I was trying to echo a form.

 <tr>
  <td><?php echo form_label($login_label, $login['id']); ?></td>
  <td><?php echo form_input($login); ?></td>    
  <td style="color: red;"><?php echo form_error($login['name']); ?><?php echo isset($errors[$login['name']])?$errors[$login['name']]:''; ?></td>    
</tr>   
<tr> 
  <td> <?php echo form_label('Password', $password['id']); ?></td>
  <td><?php echo form_password($password); ?> </td>
  <td style="color: red;"><?php echo form_error($password['name']); ?><?php echo isset($errors[$password['name']])?$errors[$password['name']]:''; ?></td>   
</tr>

The login form appears at the top left of the webpage. Is there any way to position this into the center of the page or move it around the page.

Thanks for the help.

EDIT:

I tried doing this:

<style>
  #content {
    width:500px;
    margin:0 auto ;
    text-align:center;
  }
</style>
<div id='content'>
 <tr>

        <td><?php echo form_label($login_label, $login['id']); ?></td>

        <td><?php echo form_input($login); ?></td>
        <td style="color: red;"><?php echo form_error($login['name']); ?><?php echo isset($errors[$login['name']])?$errors[$login['name']]:''; ?></td>
    </tr>
</div>

This moved the login form down but not to the side. Any ideas?

chris
  • 67
  • 2
  • 12

1 Answers1

0

wrap the form in a div and move it with css (for simplicity style is in the view but you could have it as an external stylesheet):

<style>
  #content {
    width:500px;
    margin:0px auto;
  }
</style>
<div id='content'>
 {form goes here}
</div>
Youn Elan
  • 2,379
  • 3
  • 23
  • 32
  • I edited my post...i tried what you suggested. The login form moved down, but not to the side. Any ideas? – chris Jun 10 '13 at 12:22
  • could you post the output of the page on jsfiddle? It is a bit difficult with a partial page. I also notice there is no
    . it may be that the container of the table is not wide enough.
    – Youn Elan Jun 10 '13 at 15:25
  • I just posted the full code. Thanks for all the effort that you are putting into this. – chris Jun 10 '13 at 16:19
  • well from what I see, it won't work because you are adding a div within a table. Centering would have worked if you were centering the whole table within that div or a div within a div. what you could do to center it without too many changes is adding an empty table cell before or adding padding to each table cell – Youn Elan Jun 10 '13 at 18:11
  • Haha...That's one way of doing it. It worked, and that solved the problem, for now :P Thank you very much for your help. – chris Jun 11 '13 at 05:12