28221 sujets

CSS et mise en forme, CSS3

Bonjour,

Sur la page :http://users.skynet.be/fa965254/essaiscocolo/patcocolo260105.htm, dans la zone centrale, je ne parviens pas à configurer les marges de manière que les deux blocs de texte s'affichent à égale distance G et D de leur conteneur.
J'ai essayé plusieurs réglages sans succès.
Voici le code CSS :
body {
	margin-top: 0px;
	margin-left: 0px;
	font: smaller Verdana, Arial, Helvetica, sans-serif;
}
#conteneur {
	border: 3px solid #666600;
	margin: 0px auto;
	padding: 0px;
}
#banner {
	background: url(images/logo+nom%20_banniere.gif) no-repeat left center;
	height: 140px;
}
#topnav {
	height: 30px;
	width: 100%;
	border-top: solid #000 1px;
	border-bottom: solid #000 1px;
	background-color: #C4FF88;
	text-align: right;
}
div#topnav ul {
	margin: 0px;
	padding: 0px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: smaller;
	color: #003300;
	line-height: 30px;
	white-space: nowrap;
	text-align: right;
}

div#topnav li {
list-style-type: none;
display: inline;
}

div#topnav li a {
text-decoration: none;
padding: 9px 10px;
color: #003300;
}

div#topnav li a:link {
color: #003300;
}

div#topnav li a:visited {
color: #003300;
}
div#topnav li a:hover {
font-weight: bold;
color: #003300;
background-color: #FFCC00;
}
#leftnav {
	background: #FFFFFF;
	float: left;
	height: 370px;
	width: 150px;
	border: #990066;
	text-align: center;
}
#navlist li
{
	display: inline;
/* for IE5 and IE6 */
}

#navlist
{
	width: 90%;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	padding: 0;
	font-size: smaller;
	margin: auto;
	line-height: 1.8em;
	border: 1px solid #77773C;
}

#navlist a
{
width: 99.9%;
/* extend the sensible area to the maximum with IE5 */
display: block;
background-color: #C4FF88;
text-align: center;
text-decoration: none;
color: #003300;
}

#navlist a:hover {
	background-color: #FFCC00;
	font-weight: bold;
	letter-spacing: 0.1em;
}
#navlist a:visited {
	color: #003300;
}
#rightnav {
	background: #FFFFFF;
	float: right;
	height: 370px;
	width: 150px;
	border: #990066;
	text-align: center;
}
#rightnavlist li
{
	display: inline;
/* for IE5 and IE6 */
}

#rightnavlist
{
	width: 90%;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	padding: 0;
	font-size: smaller;
	margin: auto;
	line-height: 1.8em;
	border: 1px solid #77773C;
}

#rightnavlist a
{
width: 99.9%;
/* extend the sensible area to the maximum with IE5 */
display: block;
background-color: #C4FF88;
text-align: center;
text-decoration: none;
color: #003300;
}

#rightnavlist a:hover {
	background-color: #FFCC00;
	font-weight: bold;
	letter-spacing: 0.1em;
}
#navlist a:visited {
	color: #003300;
}
#main {
	background: #FFFFFF;
	text-align: justify;
	overflow: auto;
	height: 370px;
	border-right: 1px solid #77773C;
	border-left: 1px solid #77773C;
}
#footer {
	background: #C4FF88;
	clear: both;
	height: 18px;
	border-top: 1px solid #77773C;
	font-size: smaller;
	text-align: center;
	padding-top: 7px;
	padding-bottom: 9px;
	line-height: 0.5em;
}
h4 {
	color: #FF3300;
	width: 130px;
	text-align: center;
}
.bloc1 {
	float: left;
	height: 345px;
	width: 40%;
	margin: 1%;
	border: 1px solid #C4FF88;
	padding: 5px;
	font-size: 9px;
}
.bloc2 {
	float: left;
	height: 345px;
	width: 40%;
	border: 1px solid #C4FF88;
	padding: 5px;
	font-size: 9px;
	margin: 1%;
}

Une petite aide serait très appréciée. Merci.
C'est ma première page réalisée totalement en CSS et j'y ai passé beaucoup d'heures ! Smiley smile
Modifié le 27 Jan 2005 - 18:24
Salut,

Chacun de tes blocs fait 40% de la largeur du conteneur, il faut donc que marge gauche + marge entre les deux + marge droite = 20% du conteneur.
Merci.
Cependant quelque chose m'échappe encore : lorsque je répartis les marges pour occuper les 20% restants (ex :marge gauche 7% du bloc 1, marge droite 7% du bloc 2, marges médianes 3% + 3%), les 2 blocs ne s'affichent plus côte à côte mais l'un en dessous de l'autre.
Il en est de même lorsque j'ajoute un padding (ex : 3 px) dans les 2 blocs Smiley mur . Comme le padding est une marge interne, il ne devrait pas influencer l'affichage des blocs côte à côte.
J'ai résolu le problème en faisant flotter le bloc 1 à gauche et le bloc 2 à droite. Ainsi, il reste un espace central et les 2 blocs sont également répartis.
Voici la portion de code concernée :
.bloc1 {
	float: left;
	height: 345px;
	width: 42%;
	border: 2px solid #C4FF88;
	padding: 5px;
	font-size: 9px;
	margin: 1%;
}
.bloc2 {
	float: right;
	height: 345px;
	width: 42%;
	border: 2px solid #C4FF88;
	padding: 5px;
	font-size: 9px;
	margin: 1%;

Aucun autre configuration ne m'a donné un résultat satisfaisant.
Je ne sais pas si c'est très "orthodoxe" Smiley angry mais ça marche.