CSS buttons - padding and width conflict?

I am new to CSS so if this is easy to solve then please don’t be too harsh on me !

I am trying to create some buttons using CSS but have a width / padding conflict.

This is my code (pass-thru html) on a form:

And this is my code in the html head section:

"<!–

div.allMMbuttons a {font-size:14px; font-family:Arial; font-weight:bold; color:#FFFFFF; text-decoration:none;}

div.allMMbuttons span {display:block; padding:2px;}

div.allMMbuttons a:hover {border-width:2px; border-style:solid;}

div.greyMMbuttons a {background-color:5A7E92;}

div.blueMMbuttons a {background-color:53A8FF;}

→ "

This is a good start but my problems are this:

1 - if I put width:185px in anywhere (we want all the buttons to be the same width) then the padding dissappears.

2 - when I hover over a button the border doesn’t appear all the way around.

3 - it would be nice if the words weren’t hard up against the left hand side of the button, but whenever I indent something it moves the button not the text.

Any general debugging would also be appreciated :slight_smile:

Many Thanks

Paul

Subject: CSS buttons - padding and width conflict ?

div.allMMbuttons a {font-size:14px; font-family:Arial; font-weight:bold; color:#FFFFFF; text-decoration:none;width:185px;border:2px solid #ffffff}div.allMMbuttons span {display:block;padding:2px;}

div.allMMbuttons a:hover {border:2px solid #000000;}

div.greyMMbuttons a {background-color:5A7E92;padding-left:10px;}

div.blueMMbuttons a {background-color:53A8FF;padding-left:10px;}

div.greyMMbuttons, div.blueMMbuttons {padding:2px}

div.greyMMbuttons, div.blueMMbuttons{clear:none; float:left}

  1. I put the width in div.allMMbuttons a

  2. I put the border in both div.allMMbuttons a and div.allMMbuttons a:hover. In that way the size of the button doesn’t change when you hover it. That size-changing can be very anoying for the user

  3. I put the padding (padding-left) for the words in the button in div.greyMMbuttons a and div.blueMMbuttons a

The last line is added to show the buttons one one line (I don’t know if that what you want, but i put in just in case)

Subject: RE: CSS buttons - padding and width conflict ?

Rene, thank you, thank you, thank you, happy christmas !!

One last tweak please …

I would like the buttons displayed one under the other so as instructed I removed your last line of code.

The only trouble now is that the two blues lines are merging into one (the space between the grey one and the top of the two blue ones is fine). Is there a way to fix that ?

Thanks again,

Paul

Subject: RE: CSS buttons - padding and width conflict ?

Two options:1) by HTML:put a
between the 2 hrefs in blueMMbuttons

  1. by css:

div.allMMbuttons {width:185px;}

This will make the container div too small for 2 divs on the same line.

In both cases change the line

div.greyMMbuttons, div.blueMMbuttons {padding:2px}

to

div.greyMMbuttons, div.blueMMbuttons {padding:0px}

This will make the space between the buttons equal (actually there is no space at all, but it will appear like that because of the white 2px border)

Regards & happy christmas also,

René

Subject: Thanks - CSS buttons - padding and width conflict ?

I have got things working by mixing and matching some of the ideas you both posted up. Here is my final code:

HTML HEAD:

"<!–

div.allMMbuttons a {font-size:14px; font-family:Arial; font-weight:bold; color:#FFFFFF; text-decoration:none;

display:block; padding:1px; padding-left:5px; margin:5px}

div.greyMMbuttons a {width:65px; background-color:7D7D7D; border:2px solid #7D7D7D; }

div.blueMMbuttons a {width:185px; background-color:53A8FF; border:2px solid #53A8FF; }

div.greyMMbuttons a:hover {border:2px solid #FFFFFF; }

div.blueMMbuttons a:hover {border:2px solid #FFFFFF; }

→ "

Pass Thru code on Form:

Cheers

Paul

Subject: CSS buttons - padding and width conflict ?

The standard box model works like this:

width: describes the “content” box dimension

padding: lies outside the content box

border: lies outside of the padding

margin: lies outside of the border

If you set a width, make sure that you allow for the padding, border and margin widths as well. And remember that if you add a border to something, you are changing the size of the whole deal, so you need to use a border for all of the link states, not just :HOVER. Just use the same colour for the border as you do for the link “box” if you don’t want it to look like there’s a border.

In this case, you can get rid of the span. Make the element display: block; float: left;. You can use the text-indent or text-align on the element if it is set to block rather than inline.

Oh, and make sure that you are using the full doctype (DominoCompleteDoctype=1 in the server INI) – that will keep IE 6.x from buggering things up.