Promis, avant de poster j'ai lu le tutoriel, la FAQ et le forum. Je n'ai pas trouvé (ou pas compris !) de réponses.
Je voudrais centrer un site, mais simplement horizontalement. C'est à dire qu'une page peut-être un peu plus longue qu'un écran, auquel cas elle défile vers le bas.
Dans le code proposé par le tutoriel, il faut absolument définir une hauteru. Si j'enlève cette attribut, la hauteur se fixe à 0 px, et me fait un cadre tout en haut de la page, de 1 px de hauteur.
Ci-dessous ma feuille CSS
Je voudrais centrer un site, mais simplement horizontalement. C'est à dire qu'une page peut-être un peu plus longue qu'un écran, auquel cas elle défile vers le bas.
Dans le code proposé par le tutoriel, il faut absolument définir une hauteru. Si j'enlève cette attribut, la hauteur se fixe à 0 px, et me fait un cadre tout en haut de la page, de 1 px de hauteur.
Ci-dessous ma feuille CSS
html, body {
margin: 0;
padding: 0;
background: #cccccc;
height: 100%;
font-family: arial, helvetica, verdana, sans-serif;
margin: 0; /* pour éviter les marges */
text-align: center; /* pour corriger le bug de centrage IE */
}
/*affichage des titres de premier niveau*/
h1 {
color: #cc6600;
text-align: right;
font-style: italic;
font-size: 4em;
font-weight: bold;
font-family: "Times New Roman", Arial, Georgia, Times, serif;
margin-top: 0px;
}
/*affichage des images*/
img {
margin-left: 10px;
margin-right: 10px;
border: none;
}
/*affichage des liens*/
a {
text-decoration: none;
color: teal;
}
/*affichage des liens survolés*/
a:hover {
color: red;
}
/*organisation de la page : 1 div global qui centre tout*/
#global {
margin-left: auto;
margin-right: auto;
width: 600px;
background: white;
border: 1px black solid;
text-align: left; /* on rétablit l'alignement normal du texte */
}
/*positionnement de l'entete*/
#entete {
position: absolute;
margin-top: 1px;
width: 460px;
left: 50%;
margin-left: -230px;
}
/*positionnement des éléments d'habillage de la page*/
#ambiance1{
position: absolute;
background-image: url("../public/images/bases/entete.gif");
width: 460px;
height: 95px;
}
#centre {
position: absolute;
margin-top: 140px;
margin-left: 160px;
width: 435px;
text-align: justify;
}
#projet {
position: absolute;
left: 159px;
top: 51px;
width: 82px;
height: 21px;
background: url('../public/images/bases/projet2.gif') top left no-repeat;
text-decoration: none;
}
#projet a {
display: block;
width: 100%;
height: 100%;
background: white url('../public/images/bases/projet1.gif') top left no-repeat;
color: #000;
}
#projet a:hover {background: transparent none;}
#projet2 {
position: absolute;
left: 159px;
top: 51px;
width: 82px;
height: 21px;
background: url('../public/images/bases/projet2.gif') top left no-repeat;
text-decoration: none;
}
#activite {
position: absolute;
left: 241px;
top: 51px;
width: 84px;
height: 21px;
background: url('../public/images/bases/activite2.gif') top left no-repeat;
text-decoration: none;
}
#activite a {
display: block;
width: 100%;
height: 100%;
background: white url('../public/images/bases/activite1.gif') top left no-repeat;
color: #000;
}
#activite a:hover {background: transparent none;}
#activite2 {
position: absolute;
left: 241px;
top: 51px;
width: 84px;
height: 21px;
background: url('../public/images/bases/activite2.gif') top left no-repeat;
text-decoration: none;
}
#contact {
position: absolute;
left: 325px;
top: 51px;
width: 84px;
height: 21px;
background: url('../public/images/bases/contact2.gif') top left no-repeat;
text-decoration: none;
}
#contact a {
display: block;
width: 100%;
height: 100%;
background: white url('../public/images/bases/contact1.gif') top left no-repeat;
color: #000;
}
#contact a:hover {background: transparent none;}
#contact2 {
position: absolute;
left: 325px;
top: 51px;
width: 84px;
height: 21px;
background: url('../public/images/bases/contact2.gif') top left no-repeat;
text-decoration: none;
}
#prive {
position: absolute;
left: 409px;
top: 51px;
width: 50px;
height: 21px;
background: url('../public/images/bases/prive2.gif') top left no-repeat;
text-decoration: none;
}
#prive a {
display: block;
width: 100%;
height: 100%;
background: white url('../public/images/bases/prive1.gif') top left no-repeat;
color: #000;
}
#prive a:hover {background: transparent none;}
#prive2 {
position: absolute;
left: 409px;
top: 51px;
width: 50px;
height: 21px;
background: url('../public/images/bases/prive2.gif') top left no-repeat;
text-decoration: none;
}