Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > CSS
CSS Forum d'entraide sur l'utilisation des feuilles de style CSS. Avant de poster : Cours CSS, FAQ CSS, Galerie CSS
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 21/01/2012, 11h11   #1
Futur Membre du Club
 
Avatar de eillon
 
Inscription : mars 2007
Messages : 96
Détails du profil
Informations personnelles :
Âge : 34

Informations forums :
Inscription : mars 2007
Messages : 96
Points : 16
Points : 16
Par défaut [CSS] background pour <td>

Bonjour,

Je cherche à mettre un background sous <span>, mais soit il se répète dans la <td>, soit il disparait, soit il est rogné.
Seule solution que j'ai trouvé, c'est de jouer avec des padding mais ça ne me plait pas du tout, selon les navigateurs, ils sont plus ou moins bien pris en compte.

Code :
1
2
3
4
5
6
7
8
span.promo{
	padding: 13px 5px 13px 5px;
	color: #FFF;
	font-weight:bold;
	font-size:15px;
	text-align: center;
	background-image: url('http://www.grenadineetsespetits.com/img/bouton_promo.png'); 
}
Vous trouverez la page entière ci dessous
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!DOCTYPE HTML PUBLIC "-//W3C//Dtd HTML 4.0 Transitional//EN">
<html><head><title>Newsletter grenadineetsespetits.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<style>
body{
	vertical-align:top;color:white;
	font-family:Arial,Helvetica,sans-serif;
 
	font-weight:100;
}
.under_header{
margin-left: 52px;
}
 
a, a:hover{
	text-decoration:none;
}
 
img{
 border:0px;
}
 
.product{
	padding:5px;
	background-color:white;
	width:260px;
	text-align:center;
}
 
#produits{
	margin-left: 24px;
 
	padding:5px;
	background-color:white;
	width:866px;
	text-align:center;
}
 
td{
	font-size:10px;
}
 
span.infos{
	padding: 2px;
	color: #ec3c84;
	font-weight:bold;
	font-size:15px;
	text-align: center;
	background-color: #cbdc8e;
	box-shadow: 3px 3px 5px #7f7f7f;
}
 
span.promo{
	padding: 13px 5px 13px 5px;
	color: #FFF;
	font-weight:bold;
	font-size:15px;
	text-align: center;
	background-image: url('http://www.grenadineetsespetits.com/img/bouton_promo.png'); 
}
 
span.name{
	color:#ec3c84;
	font-weight:bold;
	font-size:14px;
}
 
span.manufacturer{
	color:#ec3c84;
	font-weight:bold;
	font-size:12px;
}
.texte{
	text-align: center;
	color:black;
	padding-top: 10px;
	border-top: 1px dashed #7f7f7f;
	width:780px; 
	margin-top:25px;
}
 
</style>
<body>
<center>
<a href="http://www.grenadineetsespetits.com/newsletters/janvier_2012.html"> <span style="font-size: 8px">Consultez la version en ligne</span></a>
 
<table class="header" cellpadding="0" cellspacing="0" width="780">
<tr>
		<td>
		<a href="http://www.grenadineetsespetits.com" title="accueil">
		<img border="1" src="http://www.grenadineetsespetits.com/themes/Chrome/img/header_grenadine.png" width="920" alt="Grenadine et ses petits"></a>
 
		</td>
</tr>
</table>
 
<div id="produits">
<table class="pdt" align="center" cellpadding="0" cellspacing="0" width="780">
 
<!-- Titre Produit phare-->
 
<tr>
	<td  colspan="3" class="product" ><a href="http://www.grenadineetsespetits.com/pots-bebe-et-reducteurs-de-toilette/109-pot-evolutif-3-en-1-babysun-nursery.html"><span style="font-size: 22px;" class="name">Pot évolutif 3 en 1. BABYSUN</span></a></td></tr>	
<tr>
<td class="product">
<p style="text-align: justify;"><span style="color: #000000; font-size: small; font-family: tahoma,arial,helvetica,sans-serif;"><strong>Pot </strong><strong>&eacute;volutif </strong>3 en 1: <span style="text-decoration: underline;">pot b&eacute;b&eacute;</span> en &eacute;tape 1 puis <span style="text-decoration: underline;">rehausseur de toilette</span> (pot b&eacute;b&eacute; avec marches)&nbsp;en &eacute;tape 2 et enfin <span style="text-decoration: underline;">r&eacute;ducteur de toilette</span> en &eacute;tape 3.</span></p>
<p style="text-align: justify;"><br /><span style="color: #000000; font-size: small; font-family: tahoma,arial,helvetica,sans-serif;"> <strong>Pot &eacute;ducatif&nbsp;</strong>: avec un design sp&eacute;cialement con&ccedil;u pour familiariser les <span style="text-decoration: underline;">enfants</span> au pot, pour un <span style="text-decoration: underline;">apprentissage de la propret&eacute;</span> en douceur.</span></p>
<p style="text-align: justify;"><br /><span style="color: #000000; font-size: small; font-family: tahoma,arial,helvetica,sans-serif;"> <strong>Hygi&egrave;ne b&eacute;b&eacute;</strong>&nbsp;: sa cuvette amovible en plastique est facile &agrave; nettoyer.</span></p>
<p style="text-align: justify;"><br /><span style="color: #000000; font-size: small; font-family: tahoma,arial,helvetica,sans-serif;"> <strong>Pratique&nbsp;:</strong>&nbsp; ce <span style="text-decoration: underline;">pot b&eacute;b&eacute;</span> &eacute;volutif se plie compl&egrave;tement pour un encombrement minimum.</span></p>
<p style="text-align: justify;"><br /><span style="color: #000000; font-size: small; font-family: tahoma,arial,helvetica,sans-serif;"> <strong>S&eacute;curisant&nbsp;</strong>: dot&eacute; d&rsquo;une parfaite stabilit&eacute; avec des zones antid&eacute;rapantes pour &eacute;viter de glisser.</span></p>
 
</td>
 
<!-- Images Produit phare-->
 
	<td class="product"><a href="http://www.grenadineetsespetits.com/pots-bebe-et-reducteurs-de-toilette/109-pot-evolutif-3-en-1-babysun-nursery.html"><img border="0" src="http://www.grenadineetsespetits.com/img/potbebe3en1.jpg" width="220" alt="pot bebe 3 en 1"></a></td>
 
</tr>	
 
</table>
 
<table class="pdt" align="center" cellpadding="0" cellspacing="0" width="780">
 
<!-- Titre-->
<tr>	
	<td  style="border-top: 1px solid #cbdc8e;"class="product"><a href=""><span class="name">Veilleuse nomade</span></a></td>
 
	<td  style="border-top: 1px solid #cbdc8e;"class="product"><a href=""><span class="name">Barrière de lit Dream </span></a></td>
 
	<td  style="border-top: 1px solid #cbdc8e;"class="product"><a href=""><span class="name">Bol et couvert</span></a></td>
 
	<td  style="border-top: 1px solid #cbdc8e;"class="product"><a href=""><span class="name">Mouche bébé électrique</span></a></td>
 
	<td  style="border-top: 1px solid #cbdc8e;"class="product"><a href=""><span class="name">Kit d’accessoires poussette </span></a></td>
</tr>
 
<!-- Marques-->
<tr>	
	<td  class="product"><a href="http://www.grenadineetsespetits.com/16_pabobo"><span class="manufacturer">PABOBO</span></a></td>
 
	<td  class="product"><a href="http://www.grenadineetsespetits.com/3_dusky-moon"><span class="manufacturer">DUSKY MOON</span></a></td>
 
	<td  class="product"><a href="http://www.grenadineetsespetits.com/11_brother-max"><span class="manufacturer">BROTHER MAX</span></a></td>
 
	<td  class="product"><a href=""><span class="manufacturer">VISIOMED</span></a></td>
 
	<td  class="product"><a href="http://www.grenadineetsespetits.com/19_prince-lionheart"><span class="manufacturer">PRINCE LIONHEART</span></a></td>
</tr>
 
<!-- Images-->
 
<tr>
	<td  class="product"><a href=""><img border="0" src="http://www.grenadineetsespetits.com/img/p/32-160-thickbox.jpg" height="160" alt="veilleuse nomade Pabobo "></a></td>
 
	<td  class="product"><a href=""><img border="0" src="http://www.grenadineetsespetits.com/img/p/25-79-thickbox.jpg" height="160" alt="Barrière de lit Dream "></a></td>
 
 
	<td  class="product"><a href=""><img border="0" src="http://www.grenadineetsespetits.com/img/p/74-283-thickbox.jpg" height="160" alt="Bol et couvert"></a></td>
 
	<td  class="product"><a href=""><img border="0" src="http://www.grenadineetsespetits.com/img/p/54-209-large.jpg" height="160" alt="Mouche bébé électrique"></a></td>
 
	<td  class="product"><a href=""><img border="0" src="http://www.grenadineetsespetits.com/img/p/121-442-thickbox.jpg" height="160" alt="Kit d’accessoires poussette "></a></td>
 
</tr>
 
<!-- Infos-->
	<tr>
		<td align="center"></br>
		<a href="http://www.grenadineetsespetits.com/chambre-bebe-enfant-veilleuses/32-veilleuse-nomade-pabobo.html"><span class="infos">En promo</span></a></td>
 
 
		<td align="center"></br>
		<a href="http://www.grenadineetsespetits.com/chambre-bebe-enfant-accessoires-de-lit/25-barriere-de-lit-dreamtubes-dusky-moon.html"><span class="infos">En promo</span></a></td>
 
		<td align="center"></br>
		<a href="http://www.grenadineetsespetits.com/toutes-les-assiettes-et-les-bols-pour-le-repas-de-bebe/74-bol-et-couverts-bebe-de-voyage-brother-max.html"><span class="infos">En promo</span></a></td>
 
		<td align="center"></br>
		<a href="http://www.grenadineetsespetits.com/mouche-bebe/54-mouche-bebe-electrique-babydoo-cleaner-visiomed.html"><span class="infos">En promo</span></a></td>
 
		<td align="center"></br>
		<a href="http://www.grenadineetsespetits.com/accessoires-pour-poussette/121-kit-d-accessoires-poussettes-click-go-prince-lionheart.html"><span class="infos">Plus d'infos</span></a></td>
 
</tr>
 
<!-- Promo-->
	<tr id="promo">
		<td align="center"></br></br>
		<a href="http://www.grenadineetsespetits.com/chambre-bebe-enfant-veilleuses/32-veilleuse-nomade-pabobo.html"><span class="promo">-20%</span></a></td>
 
		<td align="center"></br></br>
		<a href="http://www.grenadineetsespetits.com/chambre-bebe-enfant-veilleuses/32-veilleuse-nomade-pabobo.html"><span class="promo">-22%</span></a></td>
 
		<td align="center"></br></br>
		<a href="http://www.grenadineetsespetits.com/chambre-bebe-enfant-veilleuses/32-veilleuse-nomade-pabobo.html"><span class="promo">-15%</span></a></td>
 
		<td align="center"></br></br>
		<a href="http://www.grenadineetsespetits.com/chambre-bebe-enfant-veilleuses/32-veilleuse-nomade-pabobo.html"><span class="promo">-20%</span></a></td>
</tr>
 
</table>
<!-- Texte sous produits
<table class="texte" align="center" cellpadding="0" cellspacing="0">
	<tr>
	<td>
	<span style="font-size: 12px;">
	Avec le code <span style="font-size: 25px; color: #ec3c84;">NOELBEBE</span>, profitez de <span style="font-size: 25px; color: #ec3c84;">5%</span> de remise supplémentaire.
	</span>
 
	</td>
</tr></table>
-->
</br>
<table align="center" cellpadding="0" cellspacing="0" style="margin-top:10px; width:865px;"><tr>
	<td valign="top" style="border-left:1px solid #ddb1c0; border-top:1px solid #ddb1c0; padding:5px;">
		<span style="font-size:12px;font-weight:bold;color:black">contact:</span><br>
		<a style="color:#951020;font-size:10px;text-decoration:none;"  href="http://www.grenadineetsespetits.com/contact-form.php">contactez nous</a>
 
	</td>
 
	<td  valign="top" style="border-top:1px solid #ddb1c0; padding:5px;">
		<span style="font-size:12px;font-weight:bold;color:black">Nos rayons:</span><br>
		<a style="color:#951020;font-size:11px;text-decoration:none;" href="http://www.grenadineetsespetits.com/5-chambre-bebe-enfant-luminaires-et-veilleuses">Son dodo</a><br>
		<a style="color:#951020;font-size:11px;text-decoration:none;" href="http://www.grenadineetsespetits.com/8-bain-bebe-enfant">Son bain</a><br>
		<a style="color:#951020;font-size:11px;text-decoration:none;" href="http://www.grenadineetsespetits.com/12-tout-pour-le-repas-de-bebe">Son repas</a><br>
		<a style="color:#951020;font-size:11px;text-decoration:none;" href="http://www.grenadineetsespetits.com/18-tout-pour-son-confort">Son confort</a><br>
 
	</td>
	<td  valign="top" style="border-top:1px solid #ddb1c0; padding:5px;">
		<span style="font-size:12px;font-weight:bold;color:black">&nbsp;</span><br>
		<a style="color:#951020;font-size:11px;text-decoration:none;" href="http://www.grenadineetsespetits.com/17-tout-pour-sa-securite">Sa sécurité</a><br>
		<a style="color:#951020;font-size:11px;text-decoration:none;" href="http://www.grenadineetsespetits.com/19-tout-pour-sa-balade">Sa balade</a><br>
		<a style="color:#951020;font-size:11px;text-decoration:none;" href="http://www.grenadineetsespetits.com/20-tout-pour-lui-faire-plaisir">Son plaisir</a><br>
		<a style="color:#951020;font-size:11px;text-decoration:none;" href="http://www.grenadineetsespetits.com/16-tout-pour-son-eveil">Son repérage dans le temps</a><br>
 
	</td>
	<td  valign="top" style=" border-top:1px solid #ddb1c0; border-right:1px solid #ddb1c0;padding:5px;">
		<span style="font-size:12px;font-weight:bold;color:black">Infos pratiques:</span><br>
		<a style="color:#951020;font-size:11px;text-decoration:none;" href="http://www.grenadineetsespetits.com/content/1-tarifs-de-livraison">Livraisons</a><br>
		<a style="color:#951020;font-size:11px;text-decoration:none;" href="http://www.grenadineetsespetits.com/content/3-conditions-generales-de-ventes">Conditions générales de ventes</a><br>
 
	</td>
</tr><tr>
 
	<td colspan="4"><img NOSEND="1" border="0" src="http://www.grenadineetsespetits.com/themes/Chrome/img/footer.png" width="865"</td>
</tr></table>
 
<span style="color:black; font-size: 10px;">Si vous ne souhaitez plus recevoir d'offres de grenadineetsespetits.com : <a href="mailto:contact@grenadineetsespetits.com?subject=Désinscription newsletter&body=Je ne souhaite plus recevoir la newsletter de Grenadine et ses petits.">Désinscription</a></span>
</div>
</center>
 
</body>
</html>
Certaines parties ne sont peut-être pas très propres, mais comme je fais des tests ça et là, il m'arrive d'oublier de retirer quelques modifs inutiles

Toutes les critiques sont les bienvenue, que ce soit dans le code ou dans la conception générale. Je ne demande qu'à apprendre.

Merci.
__________________
Si certains ont les solutions... moi j'ai les problèmes...

Je progresse...
...doucement
eillon est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/01/2012, 17h09   #2
Expert Confirmé Sénior
 
Inscription : septembre 2004
Messages : 5 092
Détails du profil
Informations forums :
Inscription : septembre 2004
Messages : 5 092
Points : 7 020
Points : 7 020
- Beurk <table>.
- Beurk mi-css mi-ancien style.
- Beurk <br>. Et d'ailleurs c'est <br> ou <br /> mais jamais </br> !

Enfin, on va faire avec.
Ce qu'il faudrait c'est que ce background s'affiche dans une boîte qui est exactement à sa taille. Ça ne peut pas être le cas du <td>, donc il va en falloir une autre. On pourra prendre le <span>. Sauf que le <span> ne sert à rien puisque c'est déjà entouré d'un <a> et qu'il suffit de styler le <a>.

Donc :
- Afficher le <a> sous forme de boîte. display: block;.
- Le mettre aux dimensions de l'image : width: 45px; height: 45px;.
- Mettre l'image de background.
- Centrer le texte horizontalement (enfin, le texte fait à peu près la largeur de l'image de toute façon) : text-align: center;.
- Centrer le texte verticalement : aïe. Le plus simple est d'utiliser vertical-align, ce qui ne marche que si la boîte est de type table-cell. Donc changer le display au-dessus et ajouter vertical-align :

Code :
1
2
display: table-cell;
vertical-align: middle;
Et en principe tu obtiens ce que tu veux.

Le centrage du texte n'aura peut-être pas l'air génial, mais c'est bien au centre. Pour que ce soit joli il faut décaler un peu du centre. Ça peut se faire en ajoutant du padding à gauche et en haut.
thelvin est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 03h08.


 
 
 
 
Partenaires

Hébergement Web