Author Topic: Removing whitespace from forms  (Read 864 times)

Offline davidjwest

  • Level 15
  • *
  • Posts: 130
  • Reputation: +0/-0
    • View Profile
    • Iron-Empire
Removing whitespace from forms
« on: December 30, 2010, 06:19:25 AM »
Hello,

I've got the following map viewer coded:

http://www.ben-hope.com/map_viewer_v5.php

As you can see the city terrain is causing problems with whitespace, these are actually submit buttons as part of a form, how can I remove this extra whitespace?

I tried this CSS:

Code: [Select]
form
{
display: inline;
margin: 0px;
padding: 0px;
border: 0px;
}

Thanks for any help.

Offline CygnusX

  • Level 24
  • *
  • Posts: 303
  • Reputation: +3/-2
    • View Profile
    • Lords of Midnight
Re: Removing whitespace from forms
« Reply #1 on: December 30, 2010, 07:08:31 AM »
Its definitely your <form> tag thats causing the spaces.  Try adding height: 0px; width: 0px; maybe?
« Last Edit: December 30, 2010, 07:42:25 AM by CygnusX »

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Removing whitespace from forms
« Reply #2 on: December 30, 2010, 08:09:52 AM »
Something is causing the form element to be 29px tall, instead of 25px like the rest of the row.

I think it's your hidden input elements in the forms, they all have margins of 2px.

Offline Harkins

  • Level 28
  • **
  • Posts: 424
  • Reputation: +11/-2
  • Coder, blogger, entrepreneur.
    • View Profile
    • Push CX - Blog
Re: Removing whitespace from forms
« Reply #3 on: December 30, 2010, 11:18:33 PM »
The problem is whitespace in the HTML. Because all of these little tiles are displayed inline, whitespace between them matters. Your <form> tags are indented in your PHP and the tabs are leaking into the HTML. Delete them, as well as the spacing between the hidden inputs.

If you had made the tiles all float left they'd be displayed in block box model and the whitespace between them would be ignored.

Visit #bbg on irc.freenode.net to talk browser games anytime.

Offline davidjwest

  • Level 15
  • *
  • Posts: 130
  • Reputation: +0/-0
    • View Profile
    • Iron-Empire
Re: Removing whitespace from forms
« Reply #4 on: December 31, 2010, 01:46:14 AM »
The problem is whitespace in the HTML. Because all of these little tiles are displayed inline, whitespace between them matters. Your <form> tags are indented in your PHP and the tabs are leaking into the HTML. Delete them, as well as the spacing between the hidden inputs.

If you had made the tiles all float left they'd be displayed in block box model and the whitespace between them would be ignored.

Nice ideas, thanks - this has made some improvement but not fixed it entirely.

The float left thing caused a bit of a mess, for some reason the <br> at the end of each row wasn't enough to force the next row of images onto the next row and so I ended up with a mess, using two <br> tags fixed that but then there's whitespace between the rows, odd.

Offline davidjwest

  • Level 15
  • *
  • Posts: 130
  • Reputation: +0/-0
    • View Profile
    • Iron-Empire
Re: Removing whitespace from forms
« Reply #5 on: December 31, 2010, 01:49:31 AM »
Its definitely your <form> tag thats causing the spaces.  Try adding height: 0px; width: 0px; maybe?

It's definitely the <form> tag as when I remove that it's fine, but this idea doesn't work, thanks for the advice though.


Offline davidjwest

  • Level 15
  • *
  • Posts: 130
  • Reputation: +0/-0
    • View Profile
    • Iron-Empire
Re: Removing whitespace from forms
« Reply #6 on: December 31, 2010, 01:50:11 AM »
Something is causing the form element to be 29px tall, instead of 25px like the rest of the row.

I think it's your hidden input elements in the forms, they all have margins of 2px.

Well spotted, but when I set margins to 0px for the input elements it doesn't fix the problem, thanks anyway.  Anyone else got any ideas?


Offline davidjwest

  • Level 15
  • *
  • Posts: 130
  • Reputation: +0/-0
    • View Profile
    • Iron-Empire
Re: Removing whitespace from forms
« Reply #7 on: December 31, 2010, 02:08:21 AM »
Harkins wins the prize, it was a \n I'd left in the PHP, thought I'd remove them all!  I was told best to use \n in the code as it helps debugging lol

Thanks everyone, I can go an lie down in a darkened room somewhere now.

 ;D

Offline Harkins

  • Level 28
  • **
  • Posts: 424
  • Reputation: +11/-2
  • Coder, blogger, entrepreneur.
    • View Profile
    • Push CX - Blog
Re: Removing whitespace from forms
« Reply #8 on: December 31, 2010, 12:03:13 PM »
Thanks everyone, I can go an lie down in a darkened room somewhere now.

Heh, glad that fixed it. This was a fun puzzle, it's the first time in years that a layout bug has stumped me for a few minutes, I used to do a ton of this for my job.

Visit #bbg on irc.freenode.net to talk browser games anytime.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal