Left Margin question

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
kelemvor
Super Advanced
Super Advanced
Posts: 39
Joined: Mon Jun 17, 2002 2:05 am

Left Margin question

Post by kelemvor »

Howdy,

I'm working on a menu with set sizes of each item to work with a background image. I want to have every item have the equivalent of 2 spaces between the edge of the "cell" and the text.

Sample at:
http://www.geocities.com/boom33/menu.htm

If the menu item is just one line, I can just put  2 spaces in front of it and it works fine. But if the words wrap to the second line, then only the first line is indented. I don't want to have to hard code line breaks so I'm looking for some other solution that can be set in the Style area preferably.

Setting the Margin for the Menu movs everything over including the background image which I don't want. I tried using padding but that padded it on the side and the top which pushed the text down too far.

Basically I just want each item to have a left margin of XX or somehow to have the text offset from the edge. Hope that makes sense.

THanks.
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Howdy back,

As far as I understand it, the margin property is only effective as a menu property and would be used to add a margin around the entire inside edge of the whole menu, rather than around each individual item (despite its appearance in the quick refs for style properties and menu item properties, it doesn't seem to actually apply when used as such, only when used as a menu property). So, I don't think that'll be useful to you.

On the other hand, the padding property should work. padding can be used as either a style property (which is probably where you'd want to set it) or as a menu item property. It seems that most folks use padding by assigning a single numeric value, like padding=5;. When used that way, as you've seen, it adds the designated number of pixels symetrically, around all sides of the menu item. But what many don't realize is that, like its CSS namesake, the padding property can also be used to set the padding for each side individually, by specifying multiple values in a string, in the order: top, right, bottom, left (just like CSS, which I imagine is how the menu applies this property internally). For example, this:

Code: Select all

padding="5 10 15 20";
would set the padding for each side as follows: top=5, right=10, bottom=15, left=20. Default measurements are in pixels, although you could also specify units of measure (padding="5px 10px 15px 20px"; ... or pt em cm mm...). You would probably do something like

Code: Select all

padding="5 5 5 25";
to add just a little more padding to the left side... with the values adjusted to your needs, of course. This will not be a problem for line wrapping.

Hope that helps,

Kevin
kelemvor
Super Advanced
Super Advanced
Posts: 39
Joined: Mon Jun 17, 2002 2:05 am

Post by kelemvor »

PERFECT!! THat's exactly what I was missing with the padding thing. GOt it workig perfectly.

Thanks!
Post Reply