HighDots Forums  

Another padding problem in Firefox

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Another padding problem in Firefox in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gustaf Liljegren
 
Posts: n/a

Default Another padding problem in Firefox - 08-09-2004 , 11:47 AM






I continued on the example shown earlier today:

http://gusgus.cn/test/index.html

Now I get some unwanted space in Firefox (the red space just below the
first image) which doesn't appear in IE6. I've double-checked the CSS
for any padding or margings than may cause it, but have found none. How
can I remove it?

Thanks,

Gustaf

Reply With Quote
  #2  
Old   
Steve Pugh
 
Posts: n/a

Default Re: Another padding problem in Firefox - 08-09-2004 , 12:44 PM






Gustaf Liljegren <gustafl (AT) algonet (DOT) se> wrote:

Quote:
I continued on the example shown earlier today:

http://gusgus.cn/test/index.html

Now I get some unwanted space in Firefox (the red space just below the
first image) which doesn't appear in IE6. I've double-checked the CSS
for any padding or margings than may cause it, but have found none. How
can I remove it?
The image is an inline element, thus it creates a line box. The image
sits on the baseline of this line box. There is room beneath the
baseline for any descenders that letters in the line box may have. The
fact that you don't have letters in there at all is irrelevant as far
as Gecko browsers like FireFox are concerned (and Opera and probably
others).

The solution is to make the image a block element so that it doesn't
generate a line box.
#top img {display: block;}

BTW, what's the point of the paragraph <p class="first last"> ? It
doesn't seem to be marking up an actual paragraph. You might want to
consider removing it.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <steve (AT) pugh (DOT) net> <http://steve.pugh.net/>


Reply With Quote
  #3  
Old   
Gustaf Liljegren
 
Posts: n/a

Default Re: Another padding problem in Firefox - 08-09-2004 , 01:25 PM



Steve Pugh wrote:

Quote:
#top img {display: block;}
Great. Thanks.

Quote:
BTW, what's the point of the paragraph <p class="first last"> ? It
doesn't seem to be marking up an actual paragraph. You might want to
consider removing it.
I know it's ugly, but I have found no other way to eliminate the
unwanted space around paragraphs. I wish to have no space above the
first <p> and no space below the last. If there's only one <p>, the
space should be supressed both above and below, so that's why all
paragraphs has this class="first last" attribute in the example.
Normally, it would look something like:

<p class="first">...</p>
<p>...</p>
<p>...</p>
<p class="last">...</p>

I'd welcome a better solution of course. :-)

Gustaf


Reply With Quote
  #4  
Old   
Arne
 
Posts: n/a

Default Re: Another padding problem in Firefox - 08-09-2004 , 01:41 PM



Gustaf Liljegren wrote:

Quote:
Steve Pugh wrote:


#top img {display: block;}


Great. Thanks.


BTW, what's the point of the paragraph <p class="first last"> ? It
doesn't seem to be marking up an actual paragraph. You might want to
consider removing it.


I know it's ugly, but I have found no other way to eliminate the
unwanted space around paragraphs. I wish to have no space above the
first <p> and no space below the last. If there's only one <p>, the
space should be supressed both above and below, so that's why all
paragraphs has this class="first last" attribute in the example.
Normally, it would look something like:

p class="first">...</p
p>...</p
p>...</p
p class="last">...</p

I'd welcome a better solution of course. :-)
An alternate solution can be that if you mostly wish to use <p> with no
margins at all (as current in your testpage above) then use

p { margin: 0px;}

and if you like, for the exeptional cases

p.first {margin-top: 0.6px;}
p.last {margin-bottom: 0.6px;}

Of cause you can change the "first" and "last" to "top" and "bottom" or
something else you like, and margins to whatever you like :-)

--
Arne
http://w1.978.telia.com/~u97802964/


Reply With Quote
  #5  
Old   
Dave Patton
 
Posts: n/a

Default Re: Another padding problem in Firefox - 08-09-2004 , 02:21 PM



Gustaf Liljegren <gustafl (AT) algonet (DOT) se> wrote in
news:cf8fl4$crb$1 (AT) green (DOT) tninet.se:

Quote:
BTW, what's the point of the paragraph <p class="first last"> ?

I know it's ugly, but I have found no other way to eliminate the
unwanted space around paragraphs. I wish to have no space above the
first <p> and no space below the last. If there's only one <p>, the
space should be supressed both above and below, so that's why all
paragraphs has this class="first last" attribute in the example.
Normally, it would look something like:

p class="first">...</p
p>...</p
p>...</p
p class="last">...</p

I'd welcome a better solution of course. :-)
I don't know how practical it is, but using
CSS2 adjacent sibling selectors you should
be able to do something along the lines of:
- wrap all paragraphs inside a div
- set the default for all paragraphs inside
the containing div to have no space above
or below
- use adjacent sibling selectors to indicate
that all paragraphs that follow a paragraph
have top spacing

--
Dave Patton
Canadian Coordinator, Degree Confluence Project
http://www.confluence.org/
My website: http://members.shaw.ca/davepatton/


Reply With Quote
  #6  
Old   
Gustaf Liljegren
 
Posts: n/a

Default Re: Another padding problem in Firefox - 08-09-2004 , 02:21 PM



I dare not start a new thread now, but I seem to have encountered yet
another padding "problem" in Firefox. My page:

http://gusgus.cn/test/

Here's the CSS that won't work:

#left {
float: left;
width: 390px;
overflow: hidden;
background-color: #DDFFDD; /* green */
text-align: justify;
padding: 10px 10px 10px 0px;
border-right: 5px solid black;
}

When the let column is rendered in Firefox, its right padding is 20
pixels, not 10. No matter what value I put there, Firefox doubles it! Is
there a reason for this too?

Gustaf

Reply With Quote
  #7  
Old   
Steve Pugh
 
Posts: n/a

Default Re: Another padding problem in Firefox - 08-09-2004 , 03:05 PM



Gustaf Liljegren <gustafl (AT) algonet (DOT) se> wrote:
Quote:
Steve Pugh wrote:

BTW, what's the point of the paragraph <p class="first last"> ? It
doesn't seem to be marking up an actual paragraph. You might want to
consider removing it.

I know it's ugly, but I have found no other way to eliminate the
unwanted space around paragraphs.
In this case why are you using a paragraph at all? Get rid of the
paragraph and you don't need to worry about the margins at all.

You have <div><p><img></p></div> with styles to remove the margins
from the <p>. Why not just <div><img></div> ?

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <steve (AT) pugh (DOT) net> <http://steve.pugh.net/>


Reply With Quote
  #8  
Old   
Gus Richter
 
Posts: n/a

Default Re: Another padding problem in Firefox - 08-10-2004 , 02:10 AM



Gustaf Liljegren wrote:
Quote:
I dare not start a new thread now, but I seem to have encountered yet
another padding "problem" in Firefox. My page:

http://gusgus.cn/test/

Here's the CSS that won't work:

#left {
float: left;
width: 390px;
overflow: hidden;
background-color: #DDFFDD; /* green */
text-align: justify;
padding: 10px 10px 10px 0px;
border-right: 5px solid black;
}

When the let column is rendered in Firefox, its right padding is 20
pixels, not 10. No matter what value I put there, Firefox doubles it! Is
there a reason for this too?

Gustaf
Since you float left, #left, it is taken out of the normal flow. Padding
(or margin) will affect the box itself which you don't want. The
solution, and proper method, is to remove the padding from #left and to
instead apply margin to its content as in:

#left {
float: left;
width: 390px;
overflow: hidden;
background-color: #DDFFDD; /* green */
text-align: justify;
/* padding: 10px 10px 10px 0px; */
border-right: 5px solid black;
}
#left p { margin: 10px 10px 10px 0; }

The reason I use margin instead of padding, is that padding would give
you extra spacing between paragraphs, whereas margin is collapsed.

--
Gus


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.