Centrer barre de recherche

Résolu
Web. Messages postés 211 Date d'inscription   Statut Membre Dernière intervention   -  
notobe Messages postés 1952 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,
Je suis en train de créer mon site et je voudrais créer une page ou il n'y a qu'une image de fond et un champ de recherche google. Je voudrais que le champ de recherche google soit centré. Comment dois-je faire ? Pouvez-vous m'aidez ?
Voici ce que j'ai pour l'instant :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>Mon Site Web.</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<!-- Champ de recherche Google -->
<center>
<FORM method=GET action="https://www.google.fr/webhp?gws_rd=ssl">
<TABLE bgcolor="#FFFFFF"><tr><td>
<A HREF="https://www.google.fr/?gws_rd=ssl">
<IMG SRC="http://www.google.com/logos/Logo_40wht.gif" border="0"
ALT="Google" align="absmiddle"></A>
<INPUT TYPE=text name=q size=31 maxlength=255 value="">
<INPUT TYPE=hidden name=hl value=fr>
<INPUT type=submit name=btnG VALUE="Recherche Google">
</td></tr></TABLE>
</FORM>
</center>
<!-- Google -->
</body>
</html>

Merci d'avance.
Web.

A voir également:

3 réponses

LordMacDragus Messages postés 11756 Date d'inscription   Statut Contributeur Dernière intervention   2 877
 
Salut,

Voilà le code :

<div align="center"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>Mon Site Web.</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<!-- Champ de recherche Google -->
<center>
<FORM method=GET action="https://www.google.fr/webhp?gws_rd=ssl">
<TABLE bgcolor="#FFFFFF"><tr><td>
<A HREF="https://www.google.fr/?gws_rd=ssl">
<IMG SRC="http://www.google.com/logos/Logo_40wht.gif" border="0"
ALT="Google" align="absmiddle"></A>
<INPUT TYPE=text name=q size=31 maxlength=255 value="">
<INPUT TYPE=hidden name=hl value=fr>
<INPUT type=submit name=btnG VALUE="Recherche Google">
</td></tr></TABLE>
</FORM>
</center>
<!-- Google -->
</body>
</html></div>


A+ =)
0
Web. Messages postés 211 Date d'inscription   Statut Membre Dernière intervention   3
 
Un grand merci à toi LordMacDragus pour cette réponse rapide !
Problème résolu !
@+ sur Commentcamarche.net
0
Web. Messages postés 211 Date d'inscription   Statut Membre Dernière intervention   3
 
Pardonne moi pour le dérangement j'aurais du préciser que quand je disais centrer c'est pour que le champ de recherche soit au milieu de la page...
:S
0
LordMacDragus Messages postés 11756 Date d'inscription   Statut Contributeur Dernière intervention   2 877
 
Alors le code est celui-ci :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" > 
<head> 
<title>Mon Site Web.</title> 
<meta http-equiv="Content-Type" content="text/html; 
charset=iso-8859-1" /> 
<!-- Champ de recherche Google --> 
<div align="center"><center> 
<FORM method=GET action="https://www.google.fr/webhp?gws_rd=ssl"> 
<TABLE bgcolor="#FFFFFF"><tr><td> 
<A HREF="https://www.google.fr/?gws_rd=ssl"> 
<IMG SRC="http://www.google.com/logos/Logo_40wht.gif" border="0" 
ALT="Google" align="absmiddle"></A> 
<INPUT TYPE=text name=q size=31 maxlength=255 value=""> 
<INPUT TYPE=hidden name=hl value=fr> 
<INPUT type=submit name=btnG VALUE="Recherche Google"> 
</td></tr></TABLE> 
</FORM> 
</center></div> 
<!-- Google --> 
</body> 
</html> 


A+ =)
0
Web. Messages postés 211 Date d'inscription   Statut Membre Dernière intervention   3
 
J'ai essayé mais cela ne marche toujours pas, le champ de recherche est centré en haut de la page et pas au centre...
:-|
0
LordMacDragus Messages postés 11756 Date d'inscription   Statut Contributeur Dernière intervention   2 877
 
Essaye ceci :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" > 
<head> 
<title>Mon Site Web.</title> 
<meta http-equiv="Content-Type" content="text/html; 
charset=iso-8859-1" /> 
<!-- Champ de recherche Google --> 
<div align="center"><div style="display:table-cell; vertical-align:middle"><center> 
<FORM method=GET action="https://www.google.fr/webhp?gws_rd=ssl"> 
<TABLE bgcolor="#FFFFFF"><tr><td> 
<A HREF="https://www.google.fr/?gws_rd=ssl"> 
<IMG SRC="http://www.google.com/logos/Logo_40wht.gif" border="0" 
ALT="Google" align="absmiddle"></A> 
<INPUT TYPE=text name=q size=31 maxlength=255 value=""> 
<INPUT TYPE=hidden name=hl value=fr> 
<INPUT type=submit name=btnG VALUE="Recherche Google"> 
</td></tr></TABLE> 
</FORM> 
</center></div></div> 
<!-- Google --> 
</body> 
</html> 
0
Anoen Messages postés 196 Date d'inscription   Statut Membre Dernière intervention   25
 
Edit: Pardon j'ai mal lu, centrer verticalement et horizontalement, tu fais
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>Mon Site Web.</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<!-- Champ de recherche Google -->

<FORM method=GET action="https://www.google.fr/webhp?gws_rd=ssl" style="margin:auto;">
<TABLE bgcolor="#FFFFFF"><tr><td>
<A HREF="https://www.google.fr/?gws_rd=ssl">
<IMG SRC="http://www.google.com/logos/Logo_40wht.gif" border="0"
ALT="Google" align="absmiddle"></A>
<INPUT TYPE=text name=q size=31 maxlength=255 value="">
<INPUT TYPE=hidden name=hl value=fr>
<INPUT type=submit name=btnG VALUE="Recherche Google">
</td></tr></TABLE>
</FORM>

<!-- Google -->
</body>
</html> 
0
Web. Messages postés 211 Date d'inscription   Statut Membre Dernière intervention   3
 
Non, ça met google dans le bord supérieur droit...
0
notobe Messages postés 1952 Date d'inscription   Statut Membre Dernière intervention   213
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" > 
<head> 
<title>Mon site web</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<style type="text/css">       
div {  
width:500px; 
height:50px; 
position:absolute; 
top:50%; 
left:50%; 
margin-left:-250px; 
margin-top:-25px; 
} 
</style> 
</head> 
<body>  
<div> 
<form method="GET" action="https://www.google.fr/webhp?gws_rd=ssl">  
<a href="https://www.google.fr/?gws_rd=ssl">  
<img src="http://www.google.com/logos/Logo_40wht.gif" alt="Google" /></a>  
<input type="text" name="q" size="31" maxlength="255" value="" />  
<input type="hidden" name="hl" value="fr" />  
<input type="submit" name="btnG" value="Recherche Google" />  
</form>   
</div> 
</body> 
</html> 


Petite précision : le doctype utilisé est du xhtml 1.0 strict => les balises doivent être écrites en minuscules, elle doivent toutes être fermées, les attributs doivent être entre guillemets et balises doivent être correctement imbriquées.
Sinon, prendre le doctype de html 4.01 transitionel.
<blockquote cite="Shakespeare">To be or not to be ; That is the question...</blockquote>
0
Web. Messages postés 211 Date d'inscription   Statut Membre Dernière intervention   3
 
Wouhou ! Ça marche !!!
Un grand merci à toi notobe.
@+
0
notobe Messages postés 1952 Date d'inscription   Statut Membre Dernière intervention   213
 
pas d'quoi :)
0