6 replies [Last post]
chickenbak
Offline
newbie
Last seen: 17 years 45 weeks ago
Timezone: GMT-6
Joined: 2004-10-03
Posts: 9
Points: 0

I am writing all this with a doctype of XHTML 1.1, intially hoping that forcing a standard rendering would alleviate some issues, unfortunately it hasn't. There are two glaring differences that I can see that I haven't been able to figure out a work around yet...

#1. padding-left in firefox/opera cause the whole div to also be stretched wide by that amount, instead of just padding the contents...is there any way around this?

#2. I have a div with nothing more than an image in it, unfortunately in firefox/opera there is a slight gap underneath of it, that I can't seem to make go away (it isn't the line break problem in IE, since it is a problem in how firefox is rendering it, and also there are no line breaks). If anyone has some ideas, that would be great!

Thanks in advance!

chickenbak
Offline
newbie
Last seen: 17 years 45 weeks ago
Timezone: GMT-6
Joined: 2004-10-03
Posts: 9
Points: 0

A few CSS problems

I figured out the latter (#2) problem, turns out that you just need to set a div height in firefox/opera, or it automatically gives images a padding it looks like. I set the height, and it worked beautifully....now if we could just figure out a workaround to the padding-left problem!

Root
Offline
Enthusiast
Brighton UK
Last seen: 15 years 26 weeks ago
Brighton UK
Joined: 2004-09-08
Posts: 76
Points: 0

A few CSS problems

It might seem wacky but adding the padding and border to the width is in accordance with the W3C spec. MS have chosen not to follow it and from some angles one can see why. But the inconsistency is the very source of much CSS misery. You either need to avoid padding etc on fixed width (height) items or you need to hack accordingly.

No class, little style and a lotta division.

chickenbak
Offline
newbie
Last seen: 17 years 45 weeks ago
Timezone: GMT-6
Joined: 2004-10-03
Posts: 9
Points: 0

A few CSS problems

Yeah, I figured out the !important hack just now...I actually far prefer the MS method just because it seems more logical, you base the width on the div itself not the content... is there any way then to add a padding-left to the content without ruining the width, except for some well placed  s?

Root
Offline
Enthusiast
Brighton UK
Last seen: 15 years 26 weeks ago
Brighton UK
Joined: 2004-09-08
Posts: 76
Points: 0

A few CSS problems

Well the trick is to think of nesting. Eg you could pad a paragraph. Alternatively if you had to you can nest a new div inside the other one.

No class, little style and a lotta division.

chickenbak
Offline
newbie
Last seen: 17 years 45 weeks ago
Timezone: GMT-6
Joined: 2004-10-03
Posts: 9
Points: 0

A few CSS problems

Is there any way to make IE behave the same way as Mozilla then, so you only have to write the code one way, maybe with a new "doctype"?

Root
Offline
Enthusiast
Brighton UK
Last seen: 15 years 26 weeks ago
Brighton UK
Joined: 2004-09-08
Posts: 76
Points: 0

A few CSS problems

Well there is no need to change the DTD. But with a degree of planning I find that very few things can not be accomplished that work across browsers without a lot of messy hacking. My own philosophy is that robustness comes thru simplicity. Plus I can understand what the heck I am doing. I follow one single discipline which I impose on myself and that is that I never add margins padding or borders (with rare exceptions) to anything with a fixed width. The second thing I do is to put all my divs involved in layout at the top of the CSS. It is far easier for me and other people to read. Lastly when I am setting up a div that is critical in positioning I try and not clutter it with a lot of styling details. Those will be in the elements nested inside like paragraphs and headers. HTH Wink

No class, little style and a lotta division.