Web Design Web Design Forum
Registration is free! Here you can view your subscribed threads, work with private messages and edit your profile and preferences Calendar Find other members Frequently Asked Questions Search
Home Web Design

Convenient web based access to our favorite web design Usenet groups

web design reviews

This is Interesting: Free Magazines for Graphics designers and webmasters  





  Last Thread  Next Thread
Author
Thread Post New Thread   

Float and padding
 

Remi Villatel




quote this post edit post

IP Loged report this post

Old Post  09-22-05 - 04:24 AM  
Hi there,

I have following CSS definitions:

div.limits { margin: 0 20px 0 20px; }

div.halfleft {
float: left;
left: 0;
width: 50%;
padding: 0 4px 0 0;
}

div.halfright {
float: right;
right: 0;
width: 50%;
padding: 0 0 0 4px;
}

.hide {
clear: both;
display: block;
visibility: hidden;
margin: 0;
padding: 0;
}

I use them this way:

<div class="limits">
<div class="halfleft">
<table ...
</table>
</div><!--/halfleft-->
<div class="halfright">
<table ...
</table>
</div><!--/halfright-->
<hr class="hide">
</div><!--/limits-->

I tried with Konqueror, Opera, Mozilla and Firefox. It works as expected
only in Opera. Everywhere else the two tables which should be side by
side with a fixed space of 8px in between are instead, the tables on the
left and on the right but the one under the other.

I tried various display properties and I found that "display: table"
works in Konqueror. Alas Mozilla and Firefox still didn't understand
what I want.

My way around was to remove the padding from "halfleft" and "halfright"
and to apply it to nested divs.

<div class="limits">
<div class="halfleft" style="padding: 0">
<div style="padding-right: 4px">
<table ...
</table>
</div>
</div><!--/halfleft-->
<div class="halfright" style="padding: 0">
<div style="padding-right: 4px">
<table ...
</table>
</div>
</div><!--/halfright-->
<hr class="hide">
</div><!--/limits-->

(That's what I call patching!) ;-)

It works everywhere but I can't help thinking "That's stupid". I use
floating divs with paddings and margins everywhere and this is the only
place where it doesn't work as it should.

The question is: Is there a way to prevent a div from adding the width
of the padding to its own defined width?

I made some tests and I discovered that the problem occurs whatever the
width of the content of the div. So I guess it's a div width problem.

Have mercy for my page that I'm about to burn... virtually.  ;-)

--
==================
Remi Villatel
maxilys_@_tele2.fr
==================


Post Follow-Up to this message ]
Re: Float and padding
 

Spartanicus




quote this post edit post

IP Loged report this post

Old Post  09-22-05 - 09:23 AM  
Remi Villatel <maxilys@SPAMCOP_tele2.fr> wrote:

>div.halfleft {
>	float: left;
>	left: 0;
>	width: 50%;
>	padding: 0 4px 0 0;
>}

The "left" box offset property only works on positioned elements. It
appears that you are new to CSS, check out the box model:
http://www.w3.org/TR/CSS21/box.html
Note that padding is added to a specified width, 50% + 4px thus ends up
larger than 50%.

>I tried with Konqueror, Opera, Mozilla and Firefox. It works as expected
>only in Opera. Everywhere else the two tables which should be side by
>side with a fixed space of 8px in between are instead, the tables on the
>left and on the right but the one under the other.

You also need to read up on the phenomena called doctype switching and
quirks vs standards mode, Google for it. Making sure that browsers run
in standard compliant mode will make Opera do the right thing as well
and display the divs beneath one another.

--
Spartanicus


Post Follow-Up to this message ]
Re: Float and padding
 

Remi Villatel




quote this post edit post

IP Loged report this post

Old Post  09-23-05 - 04:24 AM  
Spartanicus wrote:
 

> The "left" box offset property only works on positioned elements. It
> appears that you are new to CSS, check out the box model:
> http://www.w3.org/TR/CSS21/box.html

Thank you but I have the W3C archive on CSS as bedside book... well,
screenside book. I'm not a newbie since I can write CSS from the top of
my head. As for the "left: 0" statement, probably I wrote it when I was
a newbie but the W3C CSS validator doesn't even complain so it has
remained untouched. It has no effect, why bother? Even my sense of CSS
aesthetic isn't affected...

> Note that padding is added to a specified width, 50% + 4px thus ends up
> larger than 50%.

Well, I was looking for some apparently non-existant solution against
this behavior. Let's call this a misconception and I'll use my "patch"
i.e. another nested <div> without any defined width but with the padding
I'd like to apply to its parent <div>. (Grumble, stupid CSS, grumble.)

Waiting for CSS 3,

--
==================
Remi Villatel
maxilys_@_tele2.fr
==================


Post Follow-Up to this message ]
Sponsored Links
 





All times are GMT. The time now is 07:11 AM. Post New Thread   
  Previous Last Thread   Next Thread next
Stylesheets archive | Show Printable Version | Email this Page | Subscribe to this Thread

Popular forums

Adobe Photoshop forum Macromedia Flash Web Site Design
Dreamweaver FrontPage forum
JavaScript Forum XML forum
Style Sheets VRML
Forum Jump:
Rate This Thread:

 

XML RSS Feed web design latest articles Syndicate our forum via XML or simple JavaScript

Web Design archive  Database administration help  


Top Home  -  Register  -  Control Panel   -  Memberlist  -  Calendar  -  Faq  -  Search Top