Html, div, style et margin
Résolu
santiago69
Messages postés
485
Statut
Membre
-
santiago69 Messages postés 485 Statut Membre -
santiago69 Messages postés 485 Statut Membre -
Salut a tous,
Je n'arrive pas a comprendre le comportement de la propriete margin.
Soit la page suivante :
J'ai fait 3 test : test1.htm test2.htm test3.htm
margin-left est bien calculee entre le bord du premier div et le bord du deuxieme div
pourtant margin-top, est applique entre le bord de la page et le bord du premier div alors qu'il est defini dans le 2e div.
Est ce que quelqu'un peut m'expliquer ?
Cordialement
Santiago
Je n'arrive pas a comprendre le comportement de la propriete margin.
Soit la page suivante :
<html><body> <div style="width:200px ; height:200px ; background:red"> <div style="margin-left:40px ; margin-top:40px ; width:100px ; height:100px ; background:green"> </div> </div> </body></html>
J'ai fait 3 test : test1.htm test2.htm test3.htm
margin-left est bien calculee entre le bord du premier div et le bord du deuxieme div
pourtant margin-top, est applique entre le bord de la page et le bord du premier div alors qu'il est defini dans le 2e div.
Est ce que quelqu'un peut m'expliquer ?
Cordialement
Santiago
A voir également:
- Div margin top
- Html margin left - Meilleures réponses
- Html margin div - Meilleures réponses
- Set-top box - Accueil - Box & Connexion Internet
- Top site telechargement - Accueil - Outils
- Div c++ - Télécharger - Langages
- Top model international avis - Forum Consommation & Internet
- Top clip message - Forum Loisirs / Divertissements
4 réponses
Bonjour,
tu cherches à faire ca:
<html>
<body>
<div style="width:200px ; height:200px ; background:red; position:absolute;">
<div style="margin-left:40px ; width:100px ; margin-top:40px ;height:100px ; background:green">
</div>
</div>
</body>
</html>
ou ca (plus jolie à mon gout)
<html>
<body style="margin:0 ; paddin:0 ;">
<div style="width:200px ; height:200px ; background:red; position:absolute;">
<div style="margin-left:40px ; width:100px ; margin-top:40px ;height:100px ; background:green">
</div>
</div>
</body>
</html>
tu cherches à faire ca:
<html>
<body>
<div style="width:200px ; height:200px ; background:red; position:absolute;">
<div style="margin-left:40px ; width:100px ; margin-top:40px ;height:100px ; background:green">
</div>
</div>
</body>
</html>
ou ca (plus jolie à mon gout)
<html>
<body style="margin:0 ; paddin:0 ;">
<div style="width:200px ; height:200px ; background:red; position:absolute;">
<div style="margin-left:40px ; width:100px ; margin-top:40px ;height:100px ; background:green">
</div>
</div>
</body>
</html>