PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.info.authoring.CSS > padding-left, padding-right..
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
padding-left, padding-right..

Réponse
 
LinkBack Outils de la discussion
Vieux 31/03/2008, 22h10   #1 (permalink)
maya
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut padding-left, padding-right..

hi,

I recently discovered the hard way that when you had padding-right or
padding-left to a div it increases the with of the div... how do you
add left-padding or right-padding to a div w/o changing the width of it?

(for example: I have a div that's 320px wide, content inside is 300px
and I added padding-left:10px but it increased with of div to 330px.. I
want width of it to remain 320px but I need a padding on the left of 10px..)

thank you..


  Réponse avec citation
Vieux 31/03/2008, 23h02   #2 (permalink)
Jeremy
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: padding-left, padding-right..

maya wrote:
> hi,
>
> I recently discovered the hard way that when you had padding-right or
> padding-left to a div it increases the with of the div... how do you
> add left-padding or right-padding to a div w/o changing the width of it?
>
> (for example: I have a div that's 320px wide, content inside is 300px
> and I added padding-left:10px but it increased with of div to 330px.. I
> want width of it to remain 320px but I need a padding on the left of
> 10px..)
>
> thank you..
>
>


I vaguely recall something from school - I think it was called
"arithmetic" :-)

<div style="width: 300px; padding: 10px"></div>

300 + 2 * 10 = 320


All kidding aside, if for some reason you can't just subtract the
padding from the width of the box (i.e. if you're using different units
for the width and the padding) then you can just add a second box inside
the first, with no defined width and the padding you want:

<div style="width: 60%">
<div style="padding: 2em">
<p>Content</p>
</div>
</div>


Note: inline styles are for easy demonstration purposes. You shouldn't
actually use them.

Jeremy
  Réponse avec citation
Vieux 01/04/2008, 05h02   #3 (permalink)
Jeff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: padding-left, padding-right..

dorayme wrote:
> In article <47f15341$1@news.x-privat.org>, maya <maya778899@yahoo.com>
> wrote:
>
>> hi,
>>
>> I recently discovered the hard way that when you had padding-right or
>> padding-left to a div it increases the with of the div... how do you
>> add left-padding or right-padding to a div w/o changing the width of it?
>>
>> (for example: I have a div that's 320px wide, content inside is 300px
>> and I added padding-left:10px but it increased with of div to 330px.. I
>> want width of it to remain 320px but I need a padding on the left of 10px..)
>>
>> thank you..

>
> Would this example you:
>
> <http://netweaver.com.au/alt/widthPadding.html>
>
> (the padding left is exaggerated to demonstrate. The url will not be for
> the world long.)



I think it's been a while since Dorayme wrote that, as she would not
use a transitional doc-type now!

And that is one of the keys, although, oddly current FireFox seems to
use the standards mode box type with the transitional doctype.

What happens is the standards mode box model which is usually
triggered by strict doctypes, considers the width to be the width of the
contents, not the width of the box. The old box model had the width as
the width of the container, including margins and borders.

So you can do what Dorayme has done and set the width of the
container and nest another container inside that has the padding and
border set. There's a bit more on this on a post of mine on the 24th
titled Standard Module Format.

Dorayme is just a good bit ahead of me!

Jeff
>

  Réponse avec citation
Vieux 03/04/2008, 15h11   #4 (permalink)
maya
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: padding-left, padding-right..

dorayme wrote:
> In article
> <doraymeRidThis-95AA2C.15362801042008@news-vip.optusnet.com.au>,
> dorayme <doraymeRidThis@optusnet.com.au> wrote:
>
>> Well, "she" (and much more correctly "it") should have been changed by
>> me to Strict and it - no, not me! the other it, the html doc it - is now
>> Strict. So thanks Jeff.

>
> should really read
>
> Well, "she" (and much more correctly "it") should have changed it - no,
> not me! the other it, the html doc it. It is now Strict. So thanks Jeff.
>


I see.... thank you all very much for your responses...


  Réponse avec citation
Vieux 03/04/2008, 16h01   #5 (permalink)
Jeff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: padding-left, padding-right..

dorayme wrote:
> In article
> <doraymeRidThis-95AA2C.15362801042008@news-vip.optusnet.com.au>,
> dorayme <doraymeRidThis@optusnet.com.au> wrote:
>
>> Well, "she" (and much more correctly "it") should have been changed by
>> me to Strict and it - no, not me! the other it, the html doc it - is now
>> Strict. So thanks Jeff.

>
> should really read
>
> Well, "she" (and much more correctly "it") should have changed it - no,
> not me! the other it, the html doc it. It is now Strict. So thanks Jeff.


Hmm, I don't think we've discussed the gender of html docs before.
Although I can certainly understand the confusion behind what gender a
transitional page is!

Jeff
>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 04h00.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10218 seconds with 13 queries